I can't run the LunarLander-v2 env, error occurs
[2017-07-08 12:53:22,066] Making new env: LunarLander-v2
Traceback (most recent call last):
File "gym_test_CartPole.py", line 3, in <module>
env = gym.make('LunarLander-v2')
File "/home/jackie/gym/gym/envs/registration.py", line 161, in make
return registry.make(id)
File "/home/jackie/gym/gym/envs/registration.py", line 119, in make
env = spec.make()
File "/home/jackie/gym/gym/envs/registration.py", line 85, in make
cls = load(self._entry_point)
File "/home/jackie/gym/gym/envs/registration.py", line 17, in load
result = entry_point.load(False)
File "/home/jackie/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2303, in load
return self.resolve()
File "/home/jackie/anaconda3/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2309, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/home/jackie/gym/gym/envs/box2d/__init__.py", line 1, in <module>
from gym.envs.box2d.lunar_lander import LunarLander
File "/home/jackie/gym/gym/envs/box2d/lunar_lander.py", line 4, in <module>
import Box2D
File "/home/jackie/anaconda3/lib/python3.6/site-packages/Box2D/__init__.py", line 20, in <module>
from .Box2D import *
File "/home/jackie/anaconda3/lib/python3.6/site-packages/Box2D/Box2D.py", line 434, in <module>
RAND_LIMIT = _Box2D.RAND_LIMIT
AttributeError: module 'Box2D._Box2D' has no attribute 'RAND_LIMIT'
This is a known issue, and there is information here:
https://github.com/openai/gym/issues/100
I'm not sure regarding an anaconda environment if those dependencies should already be setup right, but since you're having the error, perhaps the link above can help
As @indescribable say, try pip3 install box2d box2d-kengz
@onaclov2000 Thx!
I solve this problem by building from source following instructions found here.
$ conda create -n py34 python=3.4
$ source activate py34
$ conda install -c https://conda.anaconda.org/kne pybox2d
it works well
import gym
env = gym.make('LunarLander-v2')
env.reset()
for _ in range(500):
env.render()
env.step(env.action_space.sample())
I am trying to use TensorFlow with my GPU on the CarRacing environment. This is really frustrating because TensorFlow with GPU only supports python 3.5.* and 3.6. on Windows.
It seems that Box2D doesn't work with those, but only with 3.4.
(py35_tf_gpu) C:\Users\nickb>conda install -c https://conda.anaconda.org/kne pybox2d
Fetching package metadata ...............
Solving package specifications: .
UnsatisfiableError: The following specifications were found to be in conflict:
- pybox2d -> python 3.4*
- python 3.5*
Use "conda info <package>" to see the dependencies for each package.
I tried with the newest swig (3.0.12) and 3.0.2, the one mentioned in https://github.com/openai/gym/issues/100 as working.
Neither one worked, giving the same error:
Traceback (most recent call last):
File "C:/Users/nickb/PycharmProjects/RL-Race-Car-Simulator/run.py", line 157, in <module>
main()
File "C:/Users/nickb/PycharmProjects/RL-Race-Car-Simulator/run.py", line 21, in main
run_simulator(continue_from, N, name)
File "C:/Users/nickb/PycharmProjects/RL-Race-Car-Simulator/run.py", line 62, in run_simulator
env = gym.make('CarRacing-v0')
File "C:\Users\nickb\Anaconda3\envs\py35_tf_gpu\lib\site-packages\gym\envs\registration.py", line 164, in make
return registry.make(id)
File "C:\Users\nickb\Anaconda3\envs\py35_tf_gpu\lib\site-packages\gym\envs\registration.py", line 122, in make
env = spec.make()
File "C:\Users\nickb\Anaconda3\envs\py35_tf_gpu\lib\site-packages\gym\envs\registration.py", line 88, in make
cls = load(self._entry_point)
File "C:\Users\nickb\Anaconda3\envs\py35_tf_gpu\lib\site-packages\gym\envs\registration.py", line 17, in load
result = entry_point.load(False)
File "C:\Users\nickb\Anaconda3\envs\py35_tf_gpu\lib\site-packages\pkg_resources\__init__.py", line 2409, in load
return self.resolve()
File "C:\Users\nickb\Anaconda3\envs\py35_tf_gpu\lib\site-packages\pkg_resources\__init__.py", line 2415, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "C:\Users\nickb\Anaconda3\envs\py35_tf_gpu\lib\site-packages\gym\envs\box2d\__init__.py", line 1, in <module>
from gym.envs.box2d.lunar_lander import LunarLander
File "C:\Users\nickb\Anaconda3\envs\py35_tf_gpu\lib\site-packages\gym\envs\box2d\lunar_lander.py", line 4, in <module>
import Box2D
File "C:\Users\nickb\Anaconda3\envs\py35_tf_gpu\lib\site-packages\Box2D\__init__.py", line 20, in <module>
from .Box2D import *
File "C:\Users\nickb\Anaconda3\envs\py35_tf_gpu\lib\site-packages\Box2D\Box2D.py", line 435, in <module>
_Box2D.RAND_LIMIT_swigconstant(_Box2D)
AttributeError: module '_Box2D' has no attribute 'RAND_LIMIT_swigconstant'
@nbgraham, as far as I can tell the underlying SWIG regression, which is discussed in some detail here, was addressed in this patch.
However, it seems that when you pip install Box2D you pick up a package that was built before the issue was resolved.
One solution is to use box2d-py, as @Jackiexiao suggested above. I'm running Python 3.6, so I had to build box2d-py from source by following these instructions instead of installing the pre-built 3.4 package.
As long python setup.py build picks up a version of SWIG that doesn't have the swigconstant problem, you should be fine. On a Mac, brew install swig does the trick, but I verified that building SWIG 3.0.12 from source also works.
Hope this helps!
Installing pybox2d from source seemed to work. I have no idea what minGW and MSYS are, but I have Visual Studio installed, so maybe that's why it worked.
I got this error when trying to use the monitor
raise error.DependencyNotInstalled("""Found neither the ffmpeg nor avconv executables. On OS X, you can install ffmpeg via `brew install ffmpeg`. On most Ubuntu variants, `sudo apt-get install ffmpeg` should do it. On Ubuntu 14.04, however, you'll need to install avconv with `sudo apt-get install libav-tools`.""")
gym.error.DependencyNotInstalled: Found neither the ffmpeg nor avconv executables. On OS X, you can install ffmpeg via `brew install ffmpeg`. On most Ubuntu variants, `sudo apt-get install ffmpeg` should do it. On Ubuntu 14.04, however, you'll need to install avconv with `sudo apt-get install libav-tools`.
It didn't give instructions on how to install ffmpeg on Windows. I found the ffmpeg download page, downloaded the zip, extracted it, and added the bin folder to my path and got it working.
Everything seems to be working, thanks!
pip3 install box2d box2d-kengz
python3.5 ubuntu16
pip3 install gym[box2d]
pip3 install box2d
pip3 uninstall box2d-kengz
come into the same problem.
My environment is conda,python=3.5.And I use
conda install -c https://conda.anaconda.org/kne pybox2d
finally it works.@Jackiexiao
This is still broken. building gym from source using these instructions..
pip3 install box2d box2d-kengz
solved it for me, on mac OS
Thanks for all the suggestions, but this is still broken for myself under Ubuntu 16.04 with Python 3.5.2.
This was marked as closed; what was done to resolve this fundamentally?
I had the same problem. Doing the simple
Worked for me. I'm running python 2.7, on ubuntu.
@Khev what os were you running? I think OS matters here, as I understand it, mac/windows/linux all need different steps to solve ;)
My bad -- have updated my comment :-)
@Khev I realized my comment didnt have OS either :) Fixed it too!
pip3 install box2d box2d-kengz
It helps on Ubuntu and Windows 10.
conda install swig
pip install Box2D
TDS article with more details:
https://towardsdatascience.com/how-to-install-openai-gym-in-a-windows-environment-338969e24d30
python3.5 ubuntu16
pip3 install gym[box2d]
pip3 install box2d
pip3 uninstall box2d-kengz
Important here is the command pip3 install gym[box2d]. Only installing box2d and box2d-kengz does not solve the problem for me.
pip install box2d-py worked for me on ubuntu 18.04 and python 3.7
Most helpful comment
pip3 install box2d box2d-kengz