I tried to install open gym Mario environment. Almost every tutorial tells me to do so.
from nes_py.wrappers import JoypadSpace
import gym_super_mario_bros
from gym_super_mario_bros.actions import SIMPLE_MOVEMENT
env = gym_super_mario_bros.make('SuperMarioBros-v0')
env = JoypadSpace(env, SIMPLE_MOVEMENT)
done = True
for step in range(5000):
if done:
state = env.reset()
observation, reward, done, info = env.step(env.action_space.sample())
env.render()
env.close()
Related
I am trying to implement a code for saving videos every 500 episodes while using OpenAI gym and training. I was unable to get videos every 500 episodes.
Code:
from gym import wrappers
import gym
vidsavedir = "./video"
vidsaveeachepi = 500
env = gym.make("MsPacman-v0")
env = wrappers.Monitor(env, vidsavedir, video_callable = lambda episode_id: (episode_id % vidsaveeachepi) == 0, force = True)
env.reset()
for i in range(1,2):
for step in range(1000):
env.render()
action = env.action_space.sample()
observation, reward, done, info = env.step(action)
if done:
env.reset()
print(step)
break;
print(i)
env.close()
When I print steps it shows more than 500 but the video does not save. Only one video can see in the folder.
How can I solve this issue?
Unfortunately, I always get this error message with Frappe, so I ask you that you can maybe help me and give me a few types. Thank you and I'll be happy to wait for your answer. Thanks
Error:
Exception has occurred: ModuleNotFoundError
No module named 'frappe'
File "/home/erp/frappe-bench/apps/erpnextfints/erpnextfints/erpnextfints/doctype/fints_import/fints_import.py", line 7, in
import frappe
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import now_datetime, get_datetime
Import "frappe.model.document" could not be resolvedPylancereportMissingImports***`
# -*- coding: utf-8 -*-
# Copyright (c) 2019, jHetzer and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe import _
from frappe.model.document import Document
from frappe.utils import now_datetime, get_datetime
class FinTSImport(Document):
def validate_past(self, date, field_name):
if isinstance(date, str):
date = get_datetime(date).date()
if date >= now_datetime().date():
frappe.msgprint(
_("'{0}' needs to be in the past").format(field_name)
)
return False
if (now_datetime().date() - date).days >= 90:
frappe.msgprint(
_("'{0}' is more then 90 days in the past").format(field_name)
)
return False
return True
def before_save(self):
status = True
if self.from_date is not None:
status = self.validate_past(self.from_date, "From Date")
if self.to_date is not None:
from_date = get_datetime(self.from_date).date()
if from_date > get_datetime(self.to_date).date():
status = False
frappe.msgprint(_(
"'From Date' needs to be further in the past"
" then 'To Date'"))
if self.to_date is not None:
if not self.validate_past(self.to_date, "To Date"):
status = False
if not status:
frappe.throw(_("Validation of dates failed"))
def validate(self):
self.before_save()
Screenshot of VS Code:
Each Bench has it's own Python env which is where Frappe apps & their Python dependencies are installed. This directory can be found under the respective bench's root - /home/erp/frappe-bench in your case.
You have tell VS Code to use the Python interpreter from that environment. You can do that by either
Manually setting the interpreter for your session
You may follow the instructions mentioned in the docs or this YouTube video.
Changing your current working directory
Simply cd into your bench and open VS Ccode from there - cd /home/erp/frappe-bench && code . and VS Code detects the env folder automatically and uses it as the active interpreter.
I found a gym environment on GitHub for robotics, I tried running it on collab without rendering with the following code
import gym
import panda_gym
env = gym.make('PandaReach-v2', render=True)
obs = env.reset()
done = False
while not done:
action = env.action_space.sample() # random action
obs, reward, done, info = env.step(action)
env.close()
I got the following error
import gym
import panda_gym
env = gym.make('PandaReach-v2', render=True)
obs = env.reset()
done = False
while not done:
action = env.action_space.sample() # random action
obs, reward, done, info = env.step(action)
env.close()
here is the library link:https://pypi.org/project/panda-gym
hope that i can get help
import os
import json
from collections import namedtuple
from ansible import context
from ansible.module_utils.common.collections import ImmutableDict
from ansible.utils.vars import load_extra_vars
from ansible.parsing.dataloader import DataLoader
from ansible.vars.manager import VariableManager
from ansible.inventory.manager import InventoryManager
from ansible.playbook.play import Play
from ansible.executor.playbook_executor import PlaybookExecutor
def execute_ansible_playbook(CLOUD_TO_USE=None, PLAYBOOK=None):
playbook_path = PLAYBOOK
#inventory_path = "hosts"
#Options = namedtuple('Options', ['connection', 'module_path', 'forks', 'become', 'become_method', 'become_user', 'check', 'diff', 'listhosts', 'listtasks', 'listtags', 'syntax'])
loader = DataLoader()
passwords = dict(vault_pass='secret')
inventory = InventoryManager(loader=loader, sources='inventory/' + CLOUD_TO_USE)
#inventory = InventoryManager(loader=loader, sources='localhost')
variable_manager = VariableManager(loader=loader, inventory=inventory)
executor = PlaybookExecutor(
playbooks=[playbook_path],
inventory=inventory,
variable_manager=variable_manager,
loader=loader,
passwords=passwords
)
results = executor.run()
print (results)
I got this code from Run Ansible playbook programmatically?
This is running properly for other ansible-playbooks. But now I want to pass extra_vars to an ansible-playbook. I couldn't find a proper answer.
How can I do that?
FWIW. Use ansible-runner. The documentation is not complete. All parameters are described in the source.
I created a python 3 application that has a tkinter GUI and selenium action upon clicking a button. Here is the setup.py file:
from cx_Freeze import setup, Executable
import sys
import os
from pathlib import Path
buildOptions = {"include_files":['execute.py'], "packages": ['encodings'], "includes": ['numpy.core._methods', 'numpy.lib.format'], "excludes": []}
if sys.platform=='win32':
base = "Win32GUI"
else:
base=None
executables = [
Executable('bot_gui.py', base=base)
]
home_path = str(Path.home())
user_txt_path = []
if sys.platform=='win32':
print("windows detected")
user_txt_path.append('\\user.txt')
else:
print("macos detected")
user_txt_path.append('/user.txt')
#for initialization
f = open(home_path + user_txt_path[0], "w+")
for i in range(12):
f.write("---\n")
setup(name='tachysloth',
version = '1.0',
description = 'test',
options = dict(build_exe = buildOptions),
executables = executables)
The problem is when I run python setup.py build, everything works fine; but when I run python setup.py bdist_mac, the GUI works when you click on the application (called tachysloth-1.0 below)
but when I click on a button to in the GUI to open google.com on Chrome, the button does not do anything.
If you need more information to assess this problem, please let me know and I will provide that information as soon as possible.
Thank you again.