How to Solve Mujoco Install Error in Ubuntu (Pycharm Run Error)

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;


  1. This problem occurs when you run it on terminal.

You should check your ~/.bashrc

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”

  1. 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)
#[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. ]
#[-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]


Read More:

Leave a Reply

Your email address will not be published. Required fields are marked *