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

Box2D environments import not working #1603

Closed
sritee opened this issue Jul 13, 2019 · 17 comments
Closed

Box2D environments import not working #1603

sritee opened this issue Jul 13, 2019 · 17 comments

Comments

@sritee
Copy link
Contributor

sritee commented Jul 13, 2019

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'
@sritee
Copy link
Contributor Author

sritee commented Jul 13, 2019

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

@sritee sritee closed this as completed Jul 13, 2019
@theonekeyg
Copy link

theonekeyg commented Aug 3, 2019

@sritee What python version you were using?

@sritee
Copy link
Contributor Author

sritee commented Aug 3, 2019

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

@super-pirata
Copy link
Contributor

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

@thavlik
Copy link

thavlik commented Dec 25, 2019

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.

@super-pirata
Copy link
Contributor

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

@thavlik
Copy link

thavlik commented Dec 28, 2019

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

@jlunder00
Copy link

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?

@thavlik
Copy link

thavlik commented Jan 8, 2020

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

@fhabermacher
Copy link

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)

@AbdullahRizwan
Copy link

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.

@QasimWani
Copy link

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.

@Isaac009
Copy link

Isaac009 commented Dec 23, 2020

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.

@artificial-joe
Copy link

$ pip install gym[all]

.......didnt work for me, but

$ conda install gym[all]

.....worked. Win10, python 3.6

@jschultz299
Copy link

This post solved it for me.

@Shivam310
Copy link

Shivam310 commented Aug 17, 2022

I have swig installed and added to path. Trying the swig -version command in the cmd gives the version but trying to install box 2d through any of the pip commands doesn't work and still gives me the "can't find swig.exe" error code. Unsure if I am making a mistake or this is a bug. Please help.
Python - 3.10.4
Gym - 0.22
OS - Windows 10

@pseudo-rnd-thoughts
Copy link
Contributor

In the latest version of Gym, there is now a python module that you would use.
pip install swig

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests