openai / mujoco-py

MuJoCo is a physics engine for detailed, efficient rigid body simulations with contacts. mujoco-py allows using MuJoCo from Python 3.
Other
2.81k stars 810 forks source link

Enter bug when try to install mujoco #744

Open qinmoelei opened 1 year ago

qinmoelei commented 1 year ago

My python version is 3.8.5. I download the MuJoCo version 2.1 binaries for Linux and extract to ~/.mujoco/mujoco210. I use the following code to test the installation.

import os

os.environ[ 'LD_LIBRARY_PATH'] = '$LD_LIBRARY_PATH:/home/sunshuo/.mujoco/mujoco210/bin'
import mujoco_py
print(os.environ.get("LD_LIBRARY_PATH", ""))
mj_path = mujoco_py.utils.discover_mujoco()
xml_path = os.path.join(mj_path, 'model', 'humanoid.xml')
model = mujoco_py.load_model_from_path(xml_path)
sim = mujoco_py.MjSim(model)
print(sim.data.qpos)

And it shows the exception

Traceback (most recent call last):
  File "/home/sunshuo/qml/decision-transformer/gym/test.py", line 8, in <module>
    import mujoco_py
  File "/home/sunshuo/miniconda3/envs/decision-transformer-gym/lib/python3.8/site-packages/mujoco_py/__init__.py", line 2, in <module>
    from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
  File "/home/sunshuo/miniconda3/envs/decision-transformer-gym/lib/python3.8/site-packages/mujoco_py/builder.py", line 504, in <module>
    cymj = load_cython_ext(mujoco_path)
  File "/home/sunshuo/miniconda3/envs/decision-transformer-gym/lib/python3.8/site-packages/mujoco_py/builder.py", line 76, in load_cython_ext
    _ensure_set_env_var("LD_LIBRARY_PATH", get_nvidia_lib_dir())
  File "/home/sunshuo/miniconda3/envs/decision-transformer-gym/lib/python3.8/site-packages/mujoco_py/builder.py", line 120, in _ensure_set_env_var
    raise Exception("\nMissing path to your environment variable. \n"
Exception: 
Missing path to your environment variable. 
Current values LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/sunshuo/.mujoco/mujoco210/bin
Please add following line to .bashrc:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia

But if I add the export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/nvidia, then it shows that I should add $LD_LIBRARY_PATH:/home/sunshuo/.mujoco/mujoco210/bin instead.

fionalluo commented 5 months ago

I have the same bug, how was it resolved?