When I install Mujoco on Ubuntu 18.04 LTS (Bionic Beaver):
There is no error in the terminal test, but the following error is reported when pycharm runs the test program:
Please add the following line to .bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/shubhom/.mujoco/mjpro150/bin
However, my .bashrc file has the path already added;
Solution:
- This problem occurs when you run it on terminal.
You should check your ~/.bashrc
add
export LD_LIBRARY_PATH= /path/to/.mujoco/mjpro150/binĀ {LD_LIBRARY_PATH}}
export MUJOCO_KEY_PATH= /path/to/.mujoco${MUJOCO_KEY_PATH}
and “source ~/.bashrc”
- The problem occurs when you run it on PyCharm.
You should first check if it can run successfully on the terminal.
If it’s ok on the terminal then:
Click Run -> Edit Configuration -> Environment Variables
Add to
LD_LIBRARY_PATH /path/to/.mujoco/mjpro150/bin
MUJOCO_KEY_PATH /path/to/.mujoco
Attach the test code:
import mujoco_py import os 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) #[0. 0. 1.4 1. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. # 0. 0. 0. 0. 0. 0. 0. 0. 0. 0. ] sim.step() print(sim.data.qpos) #[-1.12164337e-05 7.29847036e-22 1.39975300e+00 9.99999999e-01 # 1.80085466e-21 4.45933954e-05 -2.70143345e-20 1.30126513e-19 # -4.63561234e-05 -1.88020744e-20 -2.24492958e-06 4.79357124e-05 # -6.38208396e-04 -1.61130312e-03 -1.37554006e-03 5.54173825e-05 # -2.24492958e-06 4.79357124e-05 -6.38208396e-04 -1.61130312e-03 # -1.37554006e-03 -5.54173825e-05 -5.73572648e-05 7.63833991e-05 # -2.12765194e-05 5.73572648e-05 -7.63833991e-05 -2.12765194e-05]