openai / gym-http-api

API to access OpenAI Gym from other languages via HTTP
MIT License
292 stars 143 forks source link

TypeError: Object of type float32 is not JSON serializable #77

Open AmitPal95 opened 3 years ago

AmitPal95 commented 3 years ago

I get the following error while running a custom made environment or any predefined environment like CartPole-v0 (I am trying to use the CPP binding, but also I get a similar error with "python example_agent.py"):-

./test1

ERROR: bad HTTP response code, and also cannot parse server message: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">

500 Internal Server Error

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.

python gym_http_server.py

Server starting at: http://127.0.0.1:5000 [2021-01-21 15:31:17,337] ERROR in app: Exception on /v1/envs/ff0e588b/action_space/ [GET] Traceback (most recent call last): File "/home/amit/miniconda3/envs/cobel-spike-http-v6/lib/python3.7/site-packages/flask/app.py", line 1988, in wsgi_app response = self.full_dispatch_request() File "/home/amit/miniconda3/envs/cobel-spike-http-v6/lib/python3.7/site-packages/flask/app.py", line 1641, in full_dispatch_request rv = self.handle_user_exception(e) File "/home/amit/miniconda3/envs/cobel-spike-http-v6/lib/python3.7/site-packages/flask/app.py", line 1544, in handle_user_exception reraise(exc_type, exc_value, tb) File "/home/amit/miniconda3/envs/cobel-spike-http-v6/lib/python3.7/site-packages/flask/_compat.py", line 33, in reraise raise value File "/home/amit/miniconda3/envs/cobel-spike-http-v6/lib/python3.7/site-packages/flask/app.py", line 1639, in full_dispatch_request rv = self.dispatch_request() File "/home/amit/miniconda3/envs/cobel-spike-http-v6/lib/python3.7/site-packages/flask/app.py", line 1625, in dispatch_request return self.view_functionsrule.endpoint File "gym_http_server.py", line 278, in env_action_space_info return jsonify(info = info) File "/home/amit/miniconda3/envs/cobel-spike-http-v6/lib/python3.7/site-packages/flask/json.py", line 266, in jsonify (dumps(data, indent=indent, separators=separators), '\n'), File "/home/amit/miniconda3/envs/cobel-spike-http-v6/lib/python3.7/site-packages/flask/json.py", line 126, in dumps rv = _json.dumps(obj, kwargs) File "/home/amit/miniconda3/envs/cobel-spike-http-v6/lib/python3.7/json/init.py", line 238, in dumps kw).encode(obj) File "/home/amit/miniconda3/envs/cobel-spike-http-v6/lib/python3.7/json/encoder.py", line 199, in encode chunks = self.iterencode(o, _one_shot=True) File "/home/amit/miniconda3/envs/cobel-spike-http-v6/lib/python3.7/json/encoder.py", line 257, in iterencode return _iterencode(o, 0) File "/home/amit/miniconda3/envs/cobel-spike-http-v6/lib/python3.7/site-packages/flask/json.py", line 83, in default return _json.JSONEncoder.default(self, o) File "/home/amit/miniconda3/envs/cobel-spike-http-v6/lib/python3.7/json/encoder.py", line 179, in default raise TypeError(f'Object of type {o.class.name} ' TypeError: Object of type float32 is not JSON serializable

Kindly help me understand the problem and how to solve it.

I have -
Flask 0.11.1
Flask-Compress 1.4.0
Flask-SocketIO 2.9.6
gym 0.12.4
numpy 1.16.3
pip 19.1.1
pytest 6.2.1
requests 2.25.0

cshreyastech commented 8 months ago

same issue. Any updates on this? ERROR: bad HTTP response code, and also cannot parse server message: <!doctype html>

500 Internal Server Error

Internal Server Error

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there is an error in the application.