-
-
Notifications
You must be signed in to change notification settings - Fork 893
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
[Bug Report] Installing gymnasium[box2d] fails #245
Comments
It seems to be specific to Poetry, as I can reproduce this error when installing with Poetry, but it works for me when installing with Pip. [build-system]
- requires = ["setuptools >= 61.0.0"]
+ requires = ["setuptools >= 61.0.0", "swig"]
build-backend = "setuptools.build_meta" Other related issue: jonasschneider/box2d-py#1 |
Thank you for your research. You're right, I tried again to make it work only with pip outside of poetry and it worked. I tried the solution you provide and I can't make it work too. Since the problem is specific to Poetry, shall I close the issue here ? |
When running with poetry it doesn't seem to have the sys.path set right. |
Hi folks, I'm seeing this error consistently for the past few days trying to get Gymnasium itself seems to be installed correctly, as the initial example from the documentation works fine: (also, worth noting, I'm relatively new to Python but well-versed in programming in general)
|
Either install swig separately or |
@boclifton-MSFT try python 3.11. It didn't work on 3.10 for me. |
Does not work on 3.11 and 3.10 either. I got for python 3.10 the exact same log as @boclifton-MSFT |
I am having a similar problem installing gymnasium[box2d]. I am using: Ubuntu 24.04.1 LTS I do the following: Create the Python virtual environment:
In .bashrc, I add; Install swig:
I also install the swig Debian package, in case it is needed. Install Gymnasium with box2d: Output:
I do not encounter this problem when running with the following configuration: Ubuntu 22.04.5 LTS A possibly important difference between this configuration and the problem one is that I am not using a virtual environment in the configuration that works. Pip installs all of the packages in ~/.local/lib/python3.10/site-packages. I tried to do the same thing with Python 3.12.3, but "pip install gymnasium[box2d]" gave me an "error: externally-managed-environment" if I didn't use a virtual environment. |
@pseudo-rnd-thoughts , regarding my comment above, should I post that as a new issue? I cannot reopen this one. |
@jim-rothrock This seems to be an issue with Swig rather than Gymnasium. |
I assume that "Python swig project" is the swig installed via pip, and "swig project as an executable" is the swig installed by the swig Debian package. When the Debian swig package is installed and the pip swig package is not installed, pip install gymnasium[box2d] produces this:
If pip swig and Debian swig are installed simultaneously and I change PATH so that /usr/bin/swig is found before /home/jimr/python_venv/bin/swig, I get the "Python.h: no such file or directory" error, as above. |
Reading the error you need to install python-dev, https://stackoverflow.com/questions/21530577/fatal-error-python-h-no-such-file-or-directory |
Here is the process I used to run "pip install gymnasium[box2d]" successfully on Ubuntu 24.04.1 LTS with Gymnasium 1.0.0. In .bashrc, I added the following lines. Replace "python_venv" with your virtual environment directory.
I then executed the following commands. python3-dev was installed in order to get Python.h.
|
Describe the bug
When running
poetry add gymnasium[box2d]
orpip install gymnasium[box2d]
, the building of the wheel for box2d-py produces an error :ModuleNotFoundError: No module named 'swig'
Code example
System info
The bug is produced with poetry add or/and pip install.
Using Gymnasium 0.27 and Python 3.11
Additional context
In the pyproject.toml of Gymnasium, the box2d dependency is written as follow:
line 42
box2d = ["box2d-py ==2.3.5", "pygame ==2.1.3.dev8", "swig ==4.*"]
Since swig is required to build box2d-py, I think moving swig before box2d-py in the dependencies could solve the issue.
I would also need to be modified at line 63
The solution I use now is to specify the dependency of box2d-py before gymnasium in the pyproject.toml of my project, as follow :
Checklist
The text was updated successfully, but these errors were encountered: