isaac-sim / OmniIsaacGymEnvs

Reinforcement Learning Environments for Omniverse Isaac Gym
Other
835 stars 211 forks source link

ModuleNotFoundError: No module named 'gymnasium' #144

Open overrize opened 6 months ago

overrize commented 6 months ago

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 commented 6 months ago

I wander what case this problem

MaltheT commented 6 months ago

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 commented 6 months ago

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.