添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have run all the steps from https://gist.github.com/saratrajput/60b1310fe9d9df664f9983b38b50d5da to install mujoco (I had an error saying libglew1.5 is not available or does not exist so I installed other versions of libglew (such as libglew-dev, libglew2.2 etc which installed properly). When I run the final command 'python3 setting_state.py', it is giving me a compilation error.

{Compiling /home/vignesh/.mujoco/mujoco-py/mujoco_py/cymj.pyx because it changed.
[1/1] Cythonizing /home/vignesh/.mujoco/mujoco-py/mujoco_py/cymj.pyx
Error compiling Cython file:
------------------------------------------------------------
    See c_warning_callback, which is the C wrapper to the user defined function
    global py_warning_callback
    global mju_user_warning
    py_warning_callback = warn
    mju_user_warning = c_warning_callback
------------------------------------------------------------
/home/vignesh/.mujoco/mujoco-py/mujoco_py/cymj.pyx:92:23: Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (const char *) except * nogil'.
Error compiling Cython file:
------------------------------------------------------------
    See c_warning_callback, which is the C wrapper to the user defined function
    global py_error_callback
    global mju_user_error
    py_error_callback = err_callback
    mju_user_error = c_error_callback
------------------------------------------------------------
/home/vignesh/.mujoco/mujoco-py/mujoco_py/cymj.pyx:127:21: Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept nogil'. Exception values are incompatible. Suggest adding 'noexcept' to type 'void (const char *) except * nogil'.
CompileError                              Traceback (most recent call last)
Cell In[3], line 1
----> 1 import mujoco_py
File ~/.mujoco/mujoco-py/mujoco_py/__init__.py:2
      1 #!/usr/bin/env python
----> 2 from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
      3 from mujoco_py.generated import const
      4 from mujoco_py.mjrenderpool import MjRenderPool
File ~/.mujoco/mujoco-py/mujoco_py/builder.py:504
    500     return module.lib.__fun
    503 mujoco_path = discover_mujoco()
--> 504 cymj = load_cython_ext(mujoco_path)
    507 # Trick to expose all mj* functions from mujoco in mujoco_py.*
    508 class dict2(object):
File ~/.mujoco/mujoco-py/mujoco_py/builder.py:110, in load_cython_ext(mujoco_path)
    108             print("Import error. Trying to rebuild mujoco_py.")
    109     if mod is None:
--> 110         cext_so_path = builder.build()
    111         mod = load_dynamic_ext('cymj', cext_so_path)
    113 return mod
-> 1301         raise CompileError(None, pyx_file)
   1302     elif os.path.exists(c_file):
   1303         os.remove(c_file)
CompileError: /home/vignesh/.mujoco/mujoco-py/mujoco_py/cymj.pyx
"name": "CompileError",
    "message": "/home/vignesh/.mujoco/mujoco-py/mujoco_py/cymj.pyx",
    "stack": "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[0;31mCompileError\u001b[0m                              Traceback (most recent call last)\nCell \u001b[0;32mIn[3], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[39mimport\u001b[39;00m \u001b[39mmujoco_py\u001b[39;00m\n\nFile \u001b[0;32m~/.mujoco/mujoco-py/mujoco_py/__init__.py:2\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[39m#!/usr/bin/env python\u001b[39;00m\n\u001b[0;32m----> 2\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mmujoco_py\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mbuilder\u001b[39;00m \u001b[39mimport\u001b[39;00m cymj, ignore_mujoco_warnings, functions, MujocoException\n\u001b[1;32m      3\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mmujoco_py\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mgenerated\u001b[39;00m \u001b[39mimport\u001b[39;00m const\n\u001b[1;32m      4\u001b[0m \u001b[39mfrom\u001b[39;00m \u001b[39mmujoco_py\u001b[39;00m\u001b[39m.\u001b[39;00m\u001b[39mmjrenderpool\u001b[39;00m \u001b[39mimport\u001b[39;00m MjRenderPool\n\nFile \u001b[0;32m~/.mujoco/mujoco-py/mujoco_py/builder.py:504\u001b[0m\n\u001b[1;32m    500\u001b[0m     \u001b[39mreturn\u001b[39;00m module\u001b[39m.\u001b[39mlib\u001b[39m.\u001b[39m__fun\n\u001b[1;32m    503\u001b[0m mujoco_path \u001b[39m=\u001b[39m discover_mujoco()\n\u001b[0;32m--> 504\u001b[0m cymj \u001b[39m=\u001b[39m load_cython_ext(mujoco_path)\n\u001b[1;32m    507\u001b[0m \u001b[39m# Trick to expose all mj* functions from mujoco in mujoco_py.*\u001b[39;00m\n\u001b[1;32m    508\u001b[0m \u001b[39mclass\u001b[39;00m \u001b[39mdict2\u001b[39;00m(\u001b[39mobject\u001b[39m):\n\nFile \u001b[0;32m~/.mujoco/mujoco-py/mujoco_py/builder.py:110\u001b[0m, in \u001b[0;36mload_cython_ext\u001b[0;34m(mujoco_path)\u001b[0m\n\u001b[1;32m    108\u001b[0m             \u001b[39mprint\u001b[39m(\u001b[39m\"\u001b[39m\u001b[39mImport error. Trying to rebuild mujoco_py.\u001b[39m\u001b[39m\"\u001b[39m)\n\u001b[1;32m    109\u001b[0m     \u001b[39mif\u001b[39;00m mod \u001b[39mis\u001b[39;00m \u001b[39mNone\u001b[39;00m:\n\u001b[0;32m--> 110\u001b[0m         cext_so_path \u001b[39m=\u001b[39m builder\u001b[39m.\u001b[39;49mbuild()\n\u001b[1;32m    111\u001b[0m         mod \u001b[39m=\u001b[39m load_dynamic_ext(\u001b[39m'\u001b[39m\u001b[39mcymj\u001b[39m\u001b[39m'\u001b[39m, cext_so_path)\n\u001b[1;32m    113\u001b[0m \u001b[39mreturn\u001b[39;00m mod\n\nFile \u001b[0;32m~/.mujoco/mujoco-py/mujoco_py/builder.py:226\u001b[0m, in \u001b[0;36mMujocoExtensionBuilder.build\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    225\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39mbuild\u001b[39m(\u001b[39mself\u001b[39m):\n\u001b[0;32m--> 226\u001b[0m     built_so_file_path \u001b[39m=\u001b[39m \u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49m_build_impl()\n\u001b[1;32m    227\u001b[0m     new_so_file_path \u001b[39m=\u001b[39m \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mget_so_file_path()\n\u001b[1;32m    228\u001b[0m     move(built_so_file_path, new_so_file_path)\n\nFile \u001b[0;32m~/.mujoco/mujoco-py/mujoco_py/builder.py:296\u001b[0m, in \u001b[0;36mLinuxGPUExtensionBuilder._build_impl\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    295\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m_build_impl\u001b[39m(\u001b[39mself\u001b[39m):\n\u001b[0;32m--> 296\u001b[0m     so_file_path \u001b[39m=\u001b[39m \u001b[39msuper\u001b[39;49m()\u001b[39m.\u001b[39;49m_build_impl()\n\u001b[1;32m    297\u001b[0m     fix_shared_library(so_file_path, \u001b[39m'\u001b[39m\u001b[39mlibOpenGL.so\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mlibOpenGL.so.0\u001b[39m\u001b[39m'\u001b[39m)\n\u001b[1;32m    298\u001b[0m     fix_shared_library(so_file_path, \u001b[39m'\u001b[39m\u001b[39mlibEGL.so\u001b[39m\u001b[39m'\u001b[39m, \u001b[39m'\u001b[39m\u001b[39mlibEGL.so.1\u001b[39m\u001b[39m'\u001b[39m)\n\nFile \u001b[0;32m~/.mujoco/mujoco-py/mujoco_py/builder.py:239\u001b[0m, in \u001b[0;36mMujocoExtensionBuilder._build_impl\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m    234\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m_build_impl\u001b[39m(\u001b[39mself\u001b[39m):\n\u001b[1;32m    235\u001b[0m     dist \u001b[39m=\u001b[39m Distribution({\n\u001b[1;32m    236\u001b[0m         \u001b[39m\"\u001b[39m\u001b[39mscript_name\u001b[39m\u001b[39m\"\u001b[39m: \u001b[39mNone\u001b[39;00m,\n\u001b[1;32m    237\u001b[0m         \u001b[39m\"\u001b[39m\u001b[39mscript_args\u001b[39m\u001b[39m\"\u001b[39m: [\u001b[39m\"\u001b[39m\u001b[39mbuild_ext\u001b[39m\u001b[39m\"\u001b[39m]\n\u001b[1;32m    238\u001b[0m     })\n\u001b[0;32m--> 239\u001b[0m     dist\u001b[39m.\u001b[39mext_modules \u001b[39m=\u001b[39m cythonize([\u001b[39mself\u001b[39;49m\u001b[39m.\u001b[39;49mextension])\n\u001b[1;32m    240\u001b[0m     dist\u001b[39m.\u001b[39minclude_dirs \u001b[39m=\u001b[39m []\n\u001b[1;32m    241\u001b[0m     dist\u001b[39m.\u001b[39mcmdclass \u001b[39m=\u001b[39m {\u001b[39m'\u001b[39m\u001b[39mbuild_ext\u001b[39m\u001b[39m'\u001b[39m: custom_build_ext}\n\nFile \u001b[0;32m~/miniconda3/envs/pytorch_mu/lib/python3.8/site-packages/Cython/Build/Dependencies.py:1134\u001b[0m, in \u001b[0;36mcythonize\u001b[0;34m(module_list, exclude, nthreads, aliases, quiet, force, language, exclude_failures, show_all_warnings, **options)\u001b[0m\n\u001b[1;32m   1132\u001b[0m \u001b[39melse\u001b[39;00m:\n\u001b[1;32m   1133\u001b[0m     \u001b[39mfor\u001b[39;00m args \u001b[39min\u001b[39;00m to_compile:\n\u001b[0;32m-> 1134\u001b[0m         cythonize_one(\u001b[39m*\u001b[39;49margs)\n\u001b[1;32m   1136\u001b[0m \u001b[39mif\u001b[39;00m exclude_failures:\n\u001b[1;32m   1137\u001b[0m     failed_modules \u001b[39m=\u001b[39m \u001b[39mset\u001b[39m()\n\nFile \u001b[0;32m~/miniconda3/envs/pytorch_mu/lib/python3.8/site-packages/Cython/Build/Dependencies.py:1301\u001b[0m, in \u001b[0;36mcythonize_one\u001b[0;34m(pyx_file, c_file, fingerprint, quiet, options, raise_on_failure, embedded_metadata, full_module_name, show_all_warnings, progress)\u001b[0m\n\u001b[1;32m   1299\u001b[0m \u001b[39mif\u001b[39;00m any_failures:\n\u001b[1;32m   1300\u001b[0m     \u001b[39mif\u001b[39;00m raise_on_failure:\n\u001b[0;32m-> 1301\u001b[0m         \u001b[39mraise\u001b[39;00m CompileError(\u001b[39mNone\u001b[39;00m, pyx_file)\n\u001b[1;32m   1302\u001b[0m     \u001b[39melif\u001b[39;00m os\u001b[39m.\u001b[39mpath\u001b[39m.\u001b[39mexists(c_file):\n\u001b[1;32m   1303\u001b[0m         os\u001b[39m.\u001b[39mremove(c_file)\n\n\u001b[0;31mCompileError\u001b[0m: /home/vignesh/.mujoco/mujoco-py/mujoco_py/cymj.pyx"

I followed the same guide as you (with the exception of not creating a conda env) and got the same error. I found the solution in a github mujoco-py issue here. Also after running that, I get another error that required me to run

sudo apt-get install libglew-dev

After that I was able to run the 'python3 setting_state.py' code.

Lastly, for further reference, this here is probably a better way to install mujoco-py.

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.