Gym: Box2D environments import not working

Created on 13 Jul 2019  路  13Comments  路  Source: openai/gym

Currently, Box2D environments cannot be imported

env=gym.make('LunarLander-v2')
AttributeError: module 'gym.envs.box2d' has no attribute 'LunarLander'
env=gym.make('CarRacing-v0')
module 'gym.envs.box2d' has no attribute 'CarRacing'

Most helpful comment

For me a simple pip install Box2D solved the issue (in contrast, pip install gym[all] didn't readily work on my machine (Ubuntu 16.04, Python 3.6)

All 13 comments

Seems to be with the prelim version, installing full version with pip install 'gym[all]' solved it. Perhaps a warning would be helpful.

@sritee What python version you were using?

I think it was 2.7. I could import Box2D, but the environments wasn't working, which made it confusing.

Seems to be with the prelim version, installing full version with pip install 'gym[all]' solved it. Perhaps a warning would be helpful.

I tried this but i got a wheel error. Anyone knows how to solve this?

(...)

  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: No such file or directory
  ----------------------------------------
  ERROR: Failed building wheel for box2d-py

I was able to get pip install gym[box2d] working on Windows 10 / Python 3.7.4 by downloading prebuilt swig (http://www.swig.org/download.html lacks HTTPS but links to https://sourceforge.net/projects/swig/ - never download prebuilt binaries over http!) and adding the extracted folder to %PATH%. Installation is able to find swig.exe and everything works fine after that.

Didn't solve my problem. Still getting wheel building error

Adding the directory containing prebuilt swig.exe to %PATH% fixed error: command 'swig.exe' failed: No such file or directory for me. If it's still complaining about not finding swig.exe, it means you didn't add it to %PATH% correctly. Is cmd.exe or powershell able to find swig?

C:\Users\thavlik>swig -version

SWIG Version 4.0.1

Compiled with i686-w64-mingw32-g++ [i686-w64-mingw32]

Configured options: +pcre

Please see http://www.swig.org for reporting bugs and further information

Adding the directory containing prebuilt swig.exe to %PATH% fixed error: command 'swig.exe' failed: No such file or directory for me. If it's still complaining about not finding swig.exe, it means you didn't add it to %PATH% correctly. Is cmd.exe or powershell able to find swig?

C:\Users\thavlik>swig -version

SWIG Version 4.0.1

Compiled with i686-w64-mingw32-g++ [i686-w64-mingw32]

Configured options: +pcre

Please see http://www.swig.org for reporting bugs and further information

I'm having the same issue, I added the folder that was extracted to the path environment variable and yet it doesn't seem to be able to find swig, not even just swig -version works. Is extracting and adding the path the only steps needed for swig?

You might ensure you editing PATH under "System Variables" (the bottom section, not the top). You add the folder containing swig.exe. New command prompts should have access to swig.exe. Maybe you need to restart? Windows is strange

For me a simple pip install Box2D solved the issue (in contrast, pip install gym[all] didn't readily work on my machine (Ubuntu 16.04, Python 3.6)

For me a simple pip install Box2D solved the issue (in contrast, pip install gym[all] didn't readily work on my machine (Ubuntu 16.04, Python 3.6)

This worked for me.

I was able to get pip install gym[box2d] working on Windows 10 / Python 3.7.4 by downloading prebuilt swig (http://www.swig.org/download.html lacks HTTPS but links to https://sourceforge.net/projects/swig/ - never download prebuilt binaries over http!) and adding the extracted folder to %PATH%. Installation is able to find swig.exe and everything works fine after that.

Thanks. this fixed it.

I was able to get pip install gym[box2d] working on Windows 10 / Python 3.7.4 by downloading prebuilt swig (http://www.swig.org/download.html lacks HTTPS but links to https://sourceforge.net/projects/swig/ - never download prebuilt binaries over http!) and adding the extracted folder to %PATH%. Installation is able to find swig.exe and everything works fine after that.

Thanks. this fixed it.

====>>> Worked for me too on Ubuntu 20.04 LTS, python 3.8.5.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhan0903 picture zhan0903  路  4Comments

mdavis-xyz picture mdavis-xyz  路  3Comments

Ettrig picture Ettrig  路  3Comments

julian-ramos picture julian-ramos  路  4Comments

cpatyn picture cpatyn  路  4Comments