I am trying to run the 1.0-lunarlander-sim.ipynb file from the Deep Assist GitHub repo. But I keep getting an error: got an unexpected keyword argument 'scope'.
raw_full_pilot_policy, full_pilot_reward_data = deepq.learn(
env,
q_func=full_pilot_q_func,
max_timesteps=max_timesteps,
scope=full_pilot_scope,
**pilot_dqn_learn_kwargs
)
(without knowing deepq), by looking in it's code you can see that scope is not a valid keyword argument for the learn function.
see here:
https://github.com/openai/baselines/blob/master/baselines/deepq/deepq.py#L95
seems that it was removed in that commit, maybe install that version of openai/baselines
https://github.com/openai/baselines/blob/8c2aea2addc9f3ba36d4a0c937e6a2d09830afc7/baselines/deepq/deepq.py
Related
Web search found links to bugs, I don't write complicated code on Python, just want to confirm I understand syntax:
https://docs.python.org/3/library/pathlib.html
Path.stat(*, follow_symlinks=True)ΒΆ
But when I write Path(filepath).stat(follow_symlinks=False) I'm getting "stat() got an unexpected keyword argument 'follow_symlinks'" error. lstat() in place of stat(follow_symlinks=False) does job done.
Python 3.8.5. TIA
You're reading it correctly. You just missed the footnote. From the page you linked
Changed in version 3.10: The follow_symlinks parameter was added.
So if you want to use that keyword argument, you need Python 3.10 or newer. Otherwise, as you've already figured out, just use lstat.
I want to use assertRaises and check for the error message too. According to the docs I have to use it as a context manager.
with self.assertRaises(ValueError, msg='Invalid id format.'):
api.get_by_id('a')
This results in the following error:
TypeError: assertRaises() missing 1 required positional argument: 'callableObj'
I get the exact same error if I use it without msg.
Using it like assertRaises(exception, callable, *args, **kwds) works fine, but that obviously can't process the error message.
I don't understand why Python can't recognise the use case I'm going for.
Python 3.7.10, MacOS Monterey 12.2
Two things - first of all, it's hard to tell what actually happens but there must be some other error in your code because
with self.assertRaises(ValueError, msg='Invalid id format.'): should work perfectly fine (tested on Python 3.10)
2nd thing - msg argument does not do what you want it to do - self.assertRaises as a context manager with msg argument not working as expected
Link provided also explains how to check for error message with assertRaisesRegex
I have create a python file with the following content
from robot.libraries.BuiltIn import BuiltIn
def scroll_page_to_the_bottom():
BuiltIn().get_library_instance('AppiumLibrary').execute_script("mobile: scroll", {'direction': 'down'})
When I call from robot file with keyword scroll_page_to_the_bottom I got an error TypeError: too many positional arguments
I thought something wrong with my scripts and I try to use other mobile command such as mobile: deviceInfo and it works perfectly
Here is the working execute_script from my code BuiltIn().get_library_instance('AppiumLibrary').execute_script("mobile: deviceInfo")
My question is how to pass command with argument to execute_script?
referring to http://appium.io/docs/en/commands/mobile-command/index.html, I have use the correct format execute_script("mobile: scroll", {'direction': 'down'}) but got an error TypeError: too many positional arguments from robot execution
Your python code is calling the execute_script() method on a AppiumLibrary object, from the robotframework-appiumlibrary package. This method receives only one parameter (script), and you are passing two arguments: 1. the string "mobile: scroll" and 2. the dict {'direction': 'down'}. Hence the TypeError: too many positional arguments exception.
The second example you gave works because you passed the correct number of arguments: the string "mobile: deviceInfo".
The page http://appium.io/docs/en/commands/mobile-command/index.html documents the execute_script() method from the appium-python-client package, and this is a different package. The method you are calling is not there.
I'm porting a Python GTK application from python2 to python3, using version 3.5.2. As part of this, I'm switching to updated GTK API calls. I need to call the gtk.TextBuffer constructor, described [here][1]. Following that documentation, I wrote:
tb = gtk.TextBuffer(table=text_tag_table)
This gives the following error:
*** TypeError: gobject `GtkTextBuffer' doesn't support property 'table'
I tried removing the table= part of the call:
gtk.TextBuffer(table=text_tag_table)
This gives:
*** TypeError: GObject.__init__() takes exactly 0 arguments (1 given)
I can call the constructor without arguments, e.g., tb = gtk.TextBuffer(). I tried setting the tag table manually, like this:
tb.set_property("tag-table", text_tag_table)
This gives a warning:
__main__:1: Warning: g_object_set_property: construct property "tag-table" for object 'GtkTextBuffer' can't be set after construction
It seems like the original constructor with the table= arg should work. Can anyone help me figure out why it throws a TypeError? I did confirm using pydb that text_tag_table is an object of the correct type:
(Pdb) p text_tag_table
<Gtk.TextTagTable object at 0x7fb723d6b288 (GtkTextTagTable at 0x2b2e8e0)>
Thanks very much in advance!
The fix for this was to use the new method:
tb = gtk.TextBuffer.new(table=text_tag_table)
I'm a bit surprised that this works, but it seems fine!
I see there is a way for me page the results in python and I found the following example code:
https://bitbucket.org/jaraco/python-ldap/src/f208b6338a28/Demo/paged_search_ext_s.py
When I copy this code and try to modify it to what I need it to do when running the code I get a "TypeError: init() got an unexpected keyword argument 'cookie'"
I even reverted the code back to its default and get the same error. If someone could point me in the correct direction it would be much appreciated.
Thanks
Update your python-ldap module:
pip install python-ldap --upgrade
That class changed from this commit and mentioned:
new class API in ldap.controls, not backwards-compatible!
The problem is on this line:
req_ctrl = SimplePagedResultsControl(True,size=self.page_size,cookie='')
Find where that SimplePagedResultsControl class is defined and examine the parameter list for its constructor to get the correct constructor parameter list.
EDIT:
Looks like the constructor signature has been changed. Either upgrade as Omid Raha recommends or try the old method signature below if you are unable to upgrade for some reason.
paged_results_control = SimplePagedResultsControl(ldap.LDAP_CONTROL_PAGE_OID, True, (self.page_size, ''))