Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: module 'gym.envs.box2d' has no attribute 'LunarLander' #1423

Closed
jtchen01 opened this issue Apr 4, 2019 · 6 comments
Closed

Comments

@jtchen01
Copy link

jtchen01 commented Apr 4, 2019

System: Ubuntu 18 LTS subsystem of Windows 10

After pip installed gym, I opened python and tried to load LunarLander-v2.

I got the following message:

>>> gym.make("LunarLander-v2")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/victor/anaconda3/envs/yy/lib/python3.6/site-packages/gym/envs/registration.py", line 183, in make
    return registry.make(id, **kwargs)
  File "/home/victor/anaconda3/envs/yy/lib/python3.6/site-packages/gym/envs/registration.py", line 125, in make
    env = spec.make(**kwargs)
  File "/home/victor/anaconda3/envs/yy/lib/python3.6/site-packages/gym/envs/registration.py", line 88, in make
    cls = load(self._entry_point)
  File "/home/victor/anaconda3/envs/yy/lib/python3.6/site-packages/gym/envs/registration.py", line 18, in load
    fn = getattr(mod, attr_name)
AttributeError: module 'gym.envs.box2d' has no attribute 'LunarLander'

No immediate solution to this. I have tried to install from cloned git, or pip install it in a clean virtual machine. Neither seems to solve this issue.

@jtchen01
Copy link
Author

jtchen01 commented Apr 4, 2019

Solved.

It's not gym's problem. It stems from failure to install pybox2d.

Please refer to here:
https://stackoverflow.com/questions/44198228/install-pybox2d-for-python-3-6-with-conda-4-3-21

@alik604
Copy link

alik604 commented Jun 11, 2021

pip3 install Box2D
pip3 install box2d-py
pip3 install gym[all]
pip3 install gym[Box_2D]
import gym
env = gym.make("LunarLander-v2")

you might need SWIG - I did. More info #1603 (comment)

@charlesxu90
Copy link

charlesxu90 commented Jun 23, 2021

Problem fixed by simply running this command:

pip install Box2D

@zeeshanalipanhwar
Copy link
Contributor

zeeshanalipanhwar commented Oct 13, 2021

I am unable to install Box2D on my PyCharm env.

Building wheel for Box2D (setup.py) ... error
.
.
.
swig.exe -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir library\Box2D -keyword -w511 -D_SWIG_KWARGS -o Box2D\Box2D_wrap.
cpp Box2D\Box2D.i
  error: command 'swig.exe' failed: None
  ----------------------------------------
  ERROR: Failed building wheel for Box2D
  Running setup.py clean for Box2D
Failed to build Box2D
Installing collected packages: Box2D
    Running setup.py install for Box2D ... error
.
.
.
swig.exe -python -c++ -IBox2D -small -O -includeall -ignoremissing -w201 -globals b2Globals -outdir library\Box2D -keyword -w511 -D_SWIG_KWARGS -o Box2D\Box2D_wra
p.cpp Box2D\Box2D.i
    error: command 'swig.exe' failed: None
    ----------------------------------------

@pythonsus
Copy link

conda install swig

@jkterry1
Copy link
Collaborator

Please make sure to you pip install gym[box2d]

@openai openai locked as resolved and limited conversation to collaborators Feb 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants