MrRobb / gym-rs

OpenAI Gym bindings for Rust
MIT License
61 stars 4 forks source link

cargo run --example basic fails #6

Closed worikgh closed 4 years ago

worikgh commented 4 years ago

Fails at basic.rs::11

    let env = match client.make("CartPole-v0") {
        Ok(env) => env,
        Err(msg) => panic!("Could not make environment because of error:\n{}", msg)
    };

Should there be a CartPole-V0 file? There is not

TypeError: Object of type float32 is not JSON serializable
thread 'main' panicked at 'Could not make environment because of error:
expected value at line 1 column 1', examples/basic.rs:11:15

I am not a python hacker but looking at the python back trace it is trying to get something off the net.


Traceback (most recent call last):
  File "XXXXXXXXXXXXXXX.local/lib/python3.7/site-packages/flask/app.py", line 2446, in wsgi_app
    response = self.full_dispatch_request()
  File "XXXXXXXXXXXXXXX.local/lib/python3.7/site-packages/flask/app.py", line 1951, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "XXXXXXXXXXXXXXX.local/lib/python3.7/site-packages/flask/app.py", line 1820, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "XXXXXXXXXXXXXXX.local/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "XXXXXXXXXXXXXXX.local/lib/python3.7/site-packages/flask/app.py", line 1949, in full_dispatch_request
    rv = self.dispatch_request()
  File "XXXXXXXXXXXXXXX.local/lib/python3.7/site-packages/flask/app.py", line 1935, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "server.py", line 340, in env_observation_space_info
    return jsonify(info = info)
  File "XXXXXXXXXXXXXXX.local/lib/python3.7/site-packages/flask/json/__init__.py", line 370, in jsonify
    dumps(data, indent=indent, separators=separators) + "\n",
  File "XXXXXXXXXXXXXXX.local/lib/python3.7/site-packages/flask/json/__init__.py", line 211, in dumps
    rv = _json.dumps(obj, **kwargs)
  File "/usr/lib/python3.7/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.7/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.7/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "XXXXXXXXXXXXXXX.local/lib/python3.7/site-packages/flask/json/__init__.py", line 100, in default
    return _json.JSONEncoder.default(self, o)
  File "/usr/lib/python3.7/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
MrRobb commented 4 years ago

It seems to be an error with the python requirements (it does not support the latest versions). I will try to add support. Meanwhile I have updated the requirements.txt (11c173587495dc232f179067735a09b483a1c6dd). So, make sure to run pip3 install -r requirements.txt

worikgh commented 4 years ago

Bingo! Works for me now.