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

ModuleNotFoundError: No module named 'gymnasium' #144

Open
overrize opened this issue Mar 6, 2024 · 3 comments
Open

ModuleNotFoundError: No module named 'gymnasium' #144

overrize opened this issue Mar 6, 2024 · 3 comments

Comments

@overrize
Copy link

overrize commented Mar 6, 2024

When I run the example rlgame_train.py,it shows ModuleNotFoundError: No module named 'gymnasium' even in the conda enviroments.
``Warning: running in conda env, please deactivate before executing this script
If conda is desired please source setup_conda_env.sh in your python 3.10 conda env and run python normally
Traceback (most recent call last):
File "/home/xx/Documents/isaacsim/OmniIsaacGymEnvs/omniisaacgymenvs/scripts/rlgames_train.py", line 37, in
from omniisaacgymenvs.envs.vec_env_rlgames import VecEnvRLGames
File "/home/xxx/.local/share/ov/pkg/isaac_sim-2023.1.1/OmniIsaacGymEnvs/omniisaacgymenvs/envs/vec_env_rlgames.py", line 34, in
from omni.isaac.gym.vec_env import VecEnvBase
File "/home/xxx/.local/share/ov/pkg/isaac_sim-2023.1.1/exts/omni.isaac.gym/omni/isaac/gym/vec_env/init.py", line 9, in
from omni.isaac.gym.vec_env.vec_env_base import VecEnvBase
File "/home/xxx/.local/share/ov/pkg/isaac_sim-2023.1.1/exts/omni.isaac.gym/omni/isaac/gym/vec_env/vec_env_base.py", line 14, in
import gymnasium as gym
ModuleNotFoundError: No module named 'gymnasium'
There was an error running python

@overrize
Copy link
Author

overrize commented Mar 6, 2024

I wander what case this problem

@MaltheT
Copy link

MaltheT commented Mar 11, 2024

Hmm, I have the same problem. I solved it by changing file:
home/xx/.local/share/ov/pkg/isaac_sim-2023.1.1/exts/omni.isaac.gym/omni/isaac/gym/vec_env/vec_env_base.py

From:

import gymnasium as gym

To:

try:
    import gymnasium as gym
except ImportError:
    print("gymnasium is not installed. Installing now...")
    subprocess.check_call([sys.executable, "-m", "pip", "install", "gymnasium"])
    # Try the import again after installation
    try:
        import gymnasium as gym
        print("gymnasium installed successfully.")
    except ImportError:
        print("Failed to install gymnasium. Please install it manually.")
        exit()

@KevinGrey
Copy link

I have encountered this issue before, and the solution is as follows:
Run the python.sh file used for your experiments (replace "python.sh" with the actual file you use) and then add a space, followed by "pip -m install gym".
The principle behind this is to instruct the python to install the "gymnasium" library within its environment using the "pip -m" method.

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

3 participants