Related
I am trying to follow the steps mentioned on "Getting Started with RLlib" (https://docs.ray.io/en/latest/rllib/rllib-training.html) along with my custom environment.
However my run doesn't work in the first code block show in the guide.
This is actually the script I m trying to run:
import ray
from ray.rllib.algorithms.ppo import PPOConfig
from ray.tune.logger import pretty_print
from gym_sw_env.envs.Examplev2 import Example_v2 #this is my custom env
ray.init(ignore_reinit_error=True)
algo = (
PPOConfig()
.rollouts(num_rollout_workers=1)
.resources(num_gpus=0)
.environment(env=Example_v2)
.build()
)
While this is the error I have:
(RolloutWorker pid=24420) 2022-12-17 11:36:34,235 ERROR worker.py:763 -- Exception raised in creation task: The actor died because of an error raised in its creation task, ray::RolloutWorker.__init__() (pid=24420, ip=127.0.0.1, repr=<ray.rllib.evaluation.rollout_worker.RolloutWorker object at 0x000001693BEB1C10>)
(RolloutWorker pid=24420) File "python\ray\_raylet.pyx", line 859, in ray._raylet.execute_task
(RolloutWorker pid=24420) File "python\ray\_raylet.pyx", line 863, in ray._raylet.execute_task
(RolloutWorker pid=24420) File "python\ray\_raylet.pyx", line 810, in ray._raylet.execute_task.function_executor
(RolloutWorker pid=24420) File "C:\Users\**MYUSER**\Anaconda3\lib\site-packages\ray\_private\function_manager.py", line 674, in actor_method_executor
(RolloutWorker pid=24420) return method(__ray_actor, *args, **kwargs)
(RolloutWorker pid=24420) File "C:\Users\**MYUSER**\Anaconda3\lib\site-packages\ray\util\tracing\tracing_helper.py", line 466, in _resume_span
(RolloutWorker pid=24420) return method(self, *_args, **_kwargs)
(RolloutWorker pid=24420) File "C:\Users\**MYUSER**\Anaconda3\lib\site-packages\ray\rllib\evaluation\rollout_worker.py", line 492, in __init__
(RolloutWorker pid=24420) self.env = env_creator(copy.deepcopy(self.env_context))
(RolloutWorker pid=24420) File "C:\Users\**MYUSER**\Anaconda3\lib\site-packages\ray\rllib\algorithms\algorithm.py", line 2139, in <lambda>
(RolloutWorker pid=24420) return env_id, lambda cfg: env_specifier(cfg)
(RolloutWorker pid=24420) TypeError: __init__() takes 1 positional argument but 2 were given
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In [3], line 7
2 from ray.tune.logger import pretty_print
3 from gym_sw_env.envs.Examplev2 import Example_v2
6 algo = (
----> 7 PPOConfig()
8 .rollouts(num_rollout_workers=1)
9 .resources(num_gpus=0)
10 .environment(env=Example_v2)
11 .build()
12 )
File ~\Anaconda3\lib\site-packages\ray\rllib\algorithms\algorithm_config.py:311, in AlgorithmConfig.build(self, env, logger_creator)
308 if logger_creator is not None:
309 self.logger_creator = logger_creator
--> 311 return self.algo_class(
312 config=self.to_dict(),
313 env=self.env,
314 logger_creator=self.logger_creator,
315 )
File ~\Anaconda3\lib\site-packages\ray\rllib\algorithms\algorithm.py:414, in Algorithm.__init__(self, config, env, logger_creator, **kwargs)
402 # Initialize common evaluation_metrics to nan, before they become
403 # available. We want to make sure the metrics are always present
404 # (although their values may be nan), so that Tune does not complain
405 # when we use these as stopping criteria.
406 self.evaluation_metrics = {
407 "evaluation": {
408 "episode_reward_max": np.nan,
(...)
411 }
412 }
--> 414 super().__init__(config=config, logger_creator=logger_creator, **kwargs)
416 # Check, whether `training_iteration` is still a tune.Trainable property
417 # and has not been overridden by the user in the attempt to implement the
418 # algos logic (this should be done now inside `training_step`).
419 try:
File ~\Anaconda3\lib\site-packages\ray\tune\trainable\trainable.py:161, in Trainable.__init__(self, config, logger_creator, remote_checkpoint_dir, custom_syncer, sync_timeout)
159 start_time = time.time()
160 self._local_ip = ray.util.get_node_ip_address()
--> 161 self.setup(copy.deepcopy(self.config))
162 setup_time = time.time() - start_time
163 if setup_time > SETUP_TIME_THRESHOLD:
File ~\Anaconda3\lib\site-packages\ray\rllib\algorithms\algorithm.py:549, in Algorithm.setup(self, config)
536 except RayActorError as e:
537 # In case of an actor (remote worker) init failure, the remote worker
538 # may still exist and will be accessible, however, e.g. calling
539 # its `sample.remote()` would result in strange "property not found"
540 # errors.
541 if e.actor_init_failed:
542 # Raise the original error here that the RolloutWorker raised
543 # during its construction process. This is to enforce transparency
(...)
547 # - e.args[0].args[2]: The original Exception (e.g. a ValueError due
548 # to a config mismatch) thrown inside the actor.
--> 549 raise e.args[0].args[2]
550 # In any other case, raise the RayActorError as-is.
551 else:
552 raise e
File python\ray\_raylet.pyx:852, in ray._raylet.execute_task()
File python\ray\_raylet.pyx:906, in ray._raylet.execute_task()
File python\ray\_raylet.pyx:859, in ray._raylet.execute_task()
File python\ray\_raylet.pyx:863, in ray._raylet.execute_task()
File python\ray\_raylet.pyx:810, in ray._raylet.execute_task.function_executor()
File ~\Anaconda3\lib\site-packages\ray\_private\function_manager.py:674, in actor_method_executor()
672 return method(*args, **kwargs)
673 else:
--> 674 return method(__ray_actor, *args, **kwargs)
File ~\Anaconda3\lib\site-packages\ray\util\tracing\tracing_helper.py:466, in _resume_span()
464 # If tracing feature flag is not on, perform a no-op
465 if not _is_tracing_enabled() or _ray_trace_ctx is None:
--> 466 return method(self, *_args, **_kwargs)
468 tracer: _opentelemetry.trace.Tracer = _opentelemetry.trace.get_tracer(
469 __name__
470 )
472 # Retrieves the context from the _ray_trace_ctx dictionary we
473 # injected.
File ~\Anaconda3\lib\site-packages\ray\rllib\evaluation\rollout_worker.py:492, in __init__()
485 # Create a (single) env for this worker.
486 if not (
487 worker_index == 0
488 and num_workers > 0
489 and not policy_config.get("create_env_on_driver")
490 ):
491 # Run the `env_creator` function passing the EnvContext.
--> 492 self.env = env_creator(copy.deepcopy(self.env_context))
494 if self.env is not None:
495 # Validate environment (general validation function).
496 if not self._disable_env_checking:
File ~\Anaconda3\lib\site-packages\ray\rllib\algorithms\algorithm.py:2139, in Algorithm._get_env_id_and_creator.<locals>.<lambda>()
2137 return env_id, lambda cfg: _wrapper.remote(cfg)
2138 else:
-> 2139 return env_id, lambda cfg: env_specifier(cfg)
2141 # No env -> Env creator always returns None.
2142 elif env_specifier is None:
TypeError: __init__() takes 1 positional argument but 2 were given
Does anybody know how to resolve it? I am just following the first step of the guide.
I am just try to remove the build() method for PPOConfigure, so I have:
algo = (
PPOConfig()
.rollouts(num_rollout_workers=1)
.resources(num_gpus=0)
.environment(env=Example_v2)
)
And this doesn't produce any error. So the question may be also: is build() method necessary?
I am trying to search other errors like this, but nothing was found.
I tried to import gym as follow:
import gym
env = gym.make("Taxi-v3")
env.reset()
env.render()
then the compiler says that pygame was missing. So I installed pygame and rerun the code and got the error:
---------------------------------------------------------------------------
AssertionError Traceback (most recent call last)
Input In [8], in <cell line: 5>()
3 env = gym.make("Taxi-v3")
4 env.reset()
----> 5 env.render()
File ~\Anaconda3\envs\pytorch\lib\site-packages\gym\core.py:329, in Wrapper.render(self, *args, **kwargs)
325 def render(
326 self, *args, **kwargs
327 ) -> Optional[Union[RenderFrame, List[RenderFrame]]]:
328 """Renders the environment."""
--> 329 return self.env.render(*args, **kwargs)
File ~\Anaconda3\envs\pytorch\lib\site-packages\gym\wrappers\order_enforcing.py:51, in OrderEnforcing.render(self, *args, **kwargs)
46 if not self._disable_render_order_enforcing and not self._has_reset:
47 raise ResetNeeded(
48 "Cannot call `env.render()` before calling `env.reset()`, if this is a intended action, "
49 "set `disable_render_order_enforcing=True` on the OrderEnforcer wrapper."
50 )
---> 51 return self.env.render(*args, **kwargs)
File ~\Anaconda3\envs\pytorch\lib\site-packages\gym\wrappers\env_checker.py:53, in PassiveEnvChecker.render(self, *args, **kwargs)
51 if self.checked_render is False:
52 self.checked_render = True
---> 53 return env_render_passive_checker(self.env, *args, **kwargs)
54 else:
55 return self.env.render(*args, **kwargs)
File ~\Anaconda3\envs\pytorch\lib\site-packages\gym\utils\passive_env_checker.py:316, in env_render_passive_checker(env, *args, **kwargs)
310 else:
311 assert env.render_mode is None or env.render_mode in render_modes, (
312 "The environment was initialized successfully however with an unsupported render mode. "
313 f"Render mode: {env.render_mode}, modes: {render_modes}"
314 )
--> 316 result = env.render(*args, **kwargs)
318 # TODO: Check that the result is correct
320 return result
File ~\Anaconda3\envs\pytorch\lib\site-packages\gym\envs\toy_text\taxi.py:284, in TaxiEnv.render(self)
282 return self._render_text()
283 else: # self.render_mode in {"human", "rgb_array"}:
--> 284 return self._render_gui(self.render_mode)
File ~\Anaconda3\envs\pytorch\lib\site-packages\gym\envs\toy_text\taxi.py:302, in TaxiEnv._render_gui(self, mode)
299 elif mode == "rgb_array":
300 self.window = pygame.Surface(WINDOW_SIZE)
--> 302 assert (
303 self.window is not None
304 ), "Something went wrong with pygame. This should never happen."
305 if self.clock is None:
306 self.clock = pygame.time.Clock()
AssertionError: Something went wrong with pygame. This should never happen.
I have installed pygame with pip install pygame and the installation was successful as well.
Please help resolving this error.
try doing pip stable_baselines3
For me it forced a reinstall of gym (?) and now it works.
let me know if that worked for you.
try doing
pip install stable-baselines3[extra]
I'm learning the FLOW project and doing their tutorial06 "Networks from OpenStreetMap". In this tutorial, one should be able to use the .osm file to run the simulation. However, there is an error raised, that the .xml of the network config files are missing.
The code in jupyter-notebook is as following:
# the TestEnv environment is used to simply simulate the network
from flow.envs import TestEnv
# the Experiment class is used for running simulations
from flow.core.experiment import Experiment
# all other imports are standard
from flow.core.params import VehicleParams
from flow.core.params import NetParams
from flow.core.params import InitialConfig
from flow.core.params import EnvParams
from flow.core.params import SumoParams
from flow.networks import Network
net_params = NetParams(
osm_path='networks/bay_bridge.osm'
)
# create the remainding parameters
env_params = EnvParams()
sim_params = SumoParams(render=True)
initial_config = InitialConfig()
vehicles = VehicleParams()
vehicles.add('human', num_vehicles=100)
flow_params = dict(
exp_tag='bay_bridge',
env_name=TestEnv,
network=Network,
simulator='traci',
sim=sim_params,
env=env_params,
net=net_params,
veh=vehicles,
initial=initial_config,
)
# number of time steps
flow_params['env'].horizon = 1000
exp = Experiment(flow_params)
# run the sumo simulation
_ = exp.run(1)
and I got the error:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
<ipython-input-13-4a3adf64a06c> in <module>
13 # number of time steps
14 flow_params['env'].horizon = 1000
---> 15 exp = Experiment(flow_params)
16
17 # run the sumo simulation
~/Desktop/flow/flow/core/experiment.py in __init__(self, flow_params, custom_callables)
79
80 # Create the environment.
---> 81 self.env = create_env()
82
83 logging.info(" Starting experiment {} at {}".format(
~/Desktop/flow/flow/utils/registry.py in create_env(*_)
128 })
129
--> 130 return gym.envs.make(env_name)
131
132 return create_env, env_name
~/anaconda3/envs/flow/lib/python3.6/site-packages/gym/envs/registration.py in make(id, **kwargs)
154
155 def make(id, **kwargs):
--> 156 return registry.make(id, **kwargs)
157
158 def spec(id):
~/anaconda3/envs/flow/lib/python3.6/site-packages/gym/envs/registration.py in make(self, path, **kwargs)
99 logger.info('Making new env: %s', path)
100 spec = self.spec(path)
--> 101 env = spec.make(**kwargs)
102 # We used to have people override _reset/_step rather than
103 # reset/step. Set _gym_disable_underscore_compat = True on
~/anaconda3/envs/flow/lib/python3.6/site-packages/gym/envs/registration.py in make(self, **kwargs)
71 else:
72 cls = load(self.entry_point)
---> 73 env = cls(**_kwargs)
74
75 # Make the enviroment aware of which spec it came from.
~/Desktop/flow/flow/envs/base.py in __init__(self, env_params, sim_params, network, simulator, scenario)
162 # use the network class's network parameters to generate the necessary
163 # network components within the network kernel
--> 164 self.k.network.generate_network(self.network)
165
166 # initial the vehicles kernel using the VehicleParams object
~/Desktop/flow/flow/core/kernel/network/traci.py in generate_network(self, network)
125 elif self.network.net_params.osm_path is not None:
126 self._edges, self._connections = self.generate_net_from_osm(
--> 127 self.network.net_params)
128 else:
129 # combine all connections into a list
~/Desktop/flow/flow/core/kernel/network/traci.py in generate_net_from_osm(self, net_params)
577
578 # collect data from the generated network configuration file
--> 579 edges_dict, conn_dict = self._import_edges_from_net(net_params)
580
581 return edges_dict, conn_dict
~/Desktop/flow/flow/core/kernel/network/traci.py in _import_edges_from_net(self, net_params)
841 net_path = os.path.join(self.cfg_path, self.netfn) \
842 if net_params.template is None else self.netfn
--> 843 tree = ElementTree.parse(net_path, parser=parser)
844 root = tree.getroot()
845
~/anaconda3/envs/flow/lib/python3.6/xml/etree/ElementTree.py in parse(source, parser)
1194 """
1195 tree = ElementTree()
-> 1196 tree.parse(source, parser)
1197 return tree
1198
~/anaconda3/envs/flow/lib/python3.6/xml/etree/ElementTree.py in parse(self, source, parser)
584 close_source = False
585 if not hasattr(source, "read"):
--> 586 source = open(source, "rb")
587 close_source = True
588 try:
FileNotFoundError: [Errno 2] No such file or directory: '/home/anjie/Desktop/flow/flow/core/kernel/network/debug/cfg/bay_bridge_20200623-1345091592912709.4246037.net.xml'
I guess that, the in FLOW project, they try to use the 'netconvert' from SUMO to convert .xml files to the sumoconfig files. However, it fails at this step, that the .osm cannot be converted. But still, I cannot fix the error. BTW, the previous 5 tutorials can be run correctly.
I'm the author of this question. After investigating for hours, I found that the problem is the following command:
netconvert --osm bay_bridge.os
Error: Cannot import network data without PROJ-Library. Please install packages proj before building sumo
Quitting (on error).
Therefore, the problem is that the SUMO is not built with PROJ, and then I tried to re-build the SUMO with PROJ. However, I always encounter the problem with proj_api.h, which is not found by the ./configure command, but exists in /usr/local/includes/.
Thus, I looked into the config.log file from sumo source files, and it said:
configure:12501: checking proj_api.h usability
configure:12501: g++ -c -msse2 -mfpmath=sse -std=c++11 -O2 -DNDEBUG conftest.cpp >&5
In file included from conftest.cpp:59:
/usr/local/include/proj_api.h:37:2: error: #error 'To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'
37 | #error 'To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'
So I open the proj_api.h with root and edit the line as follows:
#ifndef ACCEPT_USE_OF_DEPRECATED_PROJ_API_H
//#error 'To use the proj_api.h you must define the macro ACCEPT_USE_OF_DEPRECATED_PROJ_API_H'
#define ACCEPT_USE_OF_DEPRECATED_PROJ_API_H 1
#endif
After all this, I successfully built the SUMO with the PROJ and everything works fine!
Usually, if you want to get the source of an object, you can get it via the inspect module:
import inspect
inspect.getsource(MyObject)
However, in a Jupyter notebook, this doesn't work:
import inspect
class Foo:
def __init__(self, info):
self.info = info
a = Foo("hi")
inspect.getsource(a)
Throws the error:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-14-048b6f0c2e9b> in <module>()
7 a = Foo("hi")
8
----> 9 inspect.getsource(a)
/usr/lib/python3.6/inspect.py in getsource(object)
963 or code object. The source code is returned as a single string. An
964 OSError is raised if the source code cannot be retrieved."""
--> 965 lines, lnum = getsourcelines(object)
966 return ''.join(lines)
967
/usr/lib/python3.6/inspect.py in getsourcelines(object)
950 raised if the source code cannot be retrieved."""
951 object = unwrap(object)
--> 952 lines, lnum = findsource(object)
953
954 if ismodule(object):
/usr/lib/python3.6/inspect.py in findsource(object)
763 is raised if the source code cannot be retrieved."""
764
--> 765 file = getsourcefile(object)
766 if file:
767 # Invalidate cache if needed.
/usr/lib/python3.6/inspect.py in getsourcefile(object)
679 Return None if no way can be identified to get the source.
680 """
--> 681 filename = getfile(object)
682 all_bytecode_suffixes = importlib.machinery.DEBUG_BYTECODE_SUFFIXES[:]
683 all_bytecode_suffixes += importlib.machinery.OPTIMIZED_BYTECODE_SUFFIXES[:]
/usr/lib/python3.6/inspect.py in getfile(object)
661 return object.co_filename
662 raise TypeError('{!r} is not a module, class, method, '
--> 663 'function, traceback, frame, or code object'.format(object))
664
665 def getmodulename(path):
TypeError: <__main__.Foo object at 0x7fb9130ee518> is not a module, class, method, function, traceback, frame, or code object
If I try to find the source of Foo (using inspect.getsource(Foo)), I get:
TypeError: <module '__main__'> is a built-in class
How do I get the source of a class defined in a Jupyter notebook?
I found a "hacky way" to get the source code of a class in a Jupyter Notebook.
Assume in a cell you have:
class MyClass:
test = 2
def __init__(self):
self.L = 5
def test(self, x):
return True
#classmethod
def forward(cls, x):
return x
Then you can extract the code using:
import inspect
from IPython.core.magics.code import extract_symbols
obj = MyClass
cell_code = "".join(inspect.linecache.getlines(new_getfile(obj)))
class_code = extract_symbols(cell_code, obj.__name__)[0][0]
print(class_code)
with new_getfile defined from here:
import inspect, sys
def new_getfile(object, _old_getfile=inspect.getfile):
if not inspect.isclass(object):
return _old_getfile(object)
# Lookup by parent module (as in current inspect)
if hasattr(object, '__module__'):
object_ = sys.modules.get(object.__module__)
if hasattr(object_, '__file__'):
return object_.__file__
# If parent module is __main__, lookup by methods (NEW)
for name, member in inspect.getmembers(object):
if inspect.isfunction(member) and object.__qualname__ + '.' + member.__name__ == member.__qualname__:
return inspect.getfile(member)
else:
raise TypeError('Source for {!r} not found'.format(object))
inspect.getfile = new_getfile
Using inspect.getsource(inspect.getfile) we can get a segment of code that deals with this:
...
if isclass(object):
if hasattr(object, '__module__'):
object = sys.modules.get(object.__module__)
if hasattr(object, '__file__'):
return object.__file__
raise TypeError('{!r} is a built-in class'.format(object))
...
It seems in ipython or Jupyter notebook, the classes/functions defined or the __main__ module does not have a __file__ attribute associated with them so inspect wasn't able to retrieve a source file. In this case you can define the classes in a separate .py file so inspect is able to retrieve the file associated with it.
I've just been moving some code over to a Ubuntu 16.04.2 anaconda setup, and am getting a type error I don't understand when calling code which works fine across numerous other machines.
The error replicates for me just off of the list all tennis markets sample code in the repo below, as well as a request like:
from betfair import Betfair
client = Betfair("app key needed here", "path to ssh key here")
client.login(username, password)
client.keep_alive()
client.list_market_book(market_ids=['1.135391020'], price_projection=dict(priceData=['EX_BEST_OFFERS']))
or
from betfair.models import MarketFilter
event_types = client.list_event_types(
MarketFilter(text_query='tennis')
)
print(len(event_types)) # 2
print(event_types[0].event_type.name) # 'Tennis'
tennis_event_type = event_types[0]
markets = client.list_market_catalogue(
MarketFilter(event_type_ids=[tennis_event_type.event_type.id])
)
markets[0].market_name
Both throw the following type error despite identical code working on a windows installation:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-69b51cf78438> in <module>()
1 event_types = client.list_event_types(
----> 2 MarketFilter(text_query='tennis')
3 )
4 print(len(event_types)) # 2
5 print(event_types[0].event_type.name) # 'Tennis'
<decorator-gen-125> in list_event_types(self, filter, locale)
/home/user/anaconda2/lib/python2.7/site-packages/betfair/utils.pyc in requires_login(func, *args, **kwargs)
121 self = args[0]
122 if self.session_token:
--> 123 return func(*args, **kwargs)
124 raise exceptions.NotLoggedIn()
/home/user/anaconda2/lib/python2.7/site-packages/betfair/betfair.pyc in list_event_types(self, filter, locale)
148 'listEventTypes',
149 utils.get_kwargs(locals()),
--> 150 model=models.EventTypeResult,
151 )
152
/home/user/anaconda2/lib/python2.7/site-packages/betfair/betfair.pyc in make_api_request(self, base, method, params, codes, model)
87 utils.check_status_code(response, codes=codes)
88 result = utils.result_or_error(response)
---> 89 return utils.process_result(result, model)
90
91 # Authentication methods
/home/user/anaconda2/lib/python2.7/site-packages/betfair/utils.pyc in process_result(result, model)
81 return result
82 if isinstance(result, collections.Sequence):
---> 83 return [model(**item) for item in result]
84 return model(**result)
85
/home/user/anaconda2/lib/python2.7/site-packages/betfair/meta/models.pyc in __init__(self, **data)
24 def __init__(self, **data):
25 super(BetfairModel, self).__init__()
---> 26 self.import_data(data)
27
28 def import_data(self, data, **kwargs):
/home/user/anaconda2/lib/python2.7/site-packages/betfair/meta/models.pyc in import_data(self, data, **kwargs)
28 def import_data(self, data, **kwargs):
29 kwargs['strict'] = False
---> 30 return super(BetfairModel, self).import_data(data, **kwargs)
/home/user/anaconda2/lib/python2.7/site-packages/schematics/models.pyc in import_data(self, raw_data, recursive, **kwargs)
269 The data to be imported.
270 """
--> 271 data = self._convert(raw_data, trusted_data=_dict(self), recursive=recursive, **kwargs)
272 self._data.converted.update(data)
273 if kwargs.get('validate'):
/home/user/anaconda2/lib/python2.7/site-packages/schematics/models.pyc in _convert(self, raw_data, context, **kwargs)
293 should_validate = getattr(context, 'validate', kwargs.get('validate', False))
294 func = validate if should_validate else convert
--> 295 return func(self._schema, self, raw_data=raw_data, oo=True, context=context, **kwargs)
296
297 def export(self, field_converter=None, role=None, app_data=None, **kwargs):
/home/user/anaconda2/lib/python2.7/site-packages/schematics/transforms.pyc in convert(cls, mutable, raw_data, **kwargs)
427
428 def convert(cls, mutable, raw_data=None, **kwargs):
--> 429 return import_loop(cls, mutable, raw_data, import_converter, **kwargs)
430
431
/home/user/anaconda2/lib/python2.7/site-packages/schematics/transforms.pyc in import_loop(schema, mutable, raw_data, field_converter, trusted_data, mapping, partial, strict, init_values, apply_defaults, convert, validate, new, oo, recursive, app_data, context)
153 field_context = context
154 try:
--> 155 value = _field_converter(field, value, field_context)
156 except (FieldError, CompoundError) as exc:
157 errors[serialized_field_name] = exc
/home/user/anaconda2/lib/python2.7/site-packages/schematics/transforms.pyc in __call__(self, *args)
354
355 def __call__(self, *args):
--> 356 return self.func(*args)
357
358
/home/user/anaconda2/lib/python2.7/site-packages/schematics/transforms.pyc in import_converter(field, value, context)
382 if value is None or value is Undefined:
383 return value
--> 384 return field.convert(value, context)
385
386
/home/user/anaconda2/lib/python2.7/site-packages/schematics/types/compound.pyc in convert(self, value, context)
34 def convert(self, value, context=None):
35 context = context or get_import_context()
---> 36 return self._convert(value, context)
37
38 def _convert(self, value, context):
/home/user/anaconda2/lib/python2.7/site-packages/schematics/types/compound.pyc in _convert(self, value, context)
131 "Input must be a mapping or '%s' instance" % self.model_class.__name__)
132 if context.convert and context.oo:
--> 133 return model_class(value, context=context)
134 else:
135 return model_class.convert(value, context=context)
TypeError: __init__() takes exactly 1 argument (3 given)
Somewhat weirder, a request like:
client.list_market_catalogue(MarketFilter(market_ids=['1.135391020']))
Works fine.
python 2.7.13, Anaconda 4.4.0, Ubuntu 16.04.2
Any idea what could be causing this?
From the trace it looks to me like the schematics library is your issue. Checking the open issues on the betfair github there is, as of this writing, an open ticket regarding schematics breaking the api. It would appear that the author has left schematics out of the requirements and that version 1.1.1 is required. My guess is you have schematics 2.0 installed on the computer causing the issue.
One way to find this in the future would be to pip freeze the working environment and diff the broken environment. Moreover, when moving to a new machine you can use the output of pip freeze to duplicate the environment and avoid messy version issues like this.