[已解决] Cython.Compiler.Errors.CompileError: /root/anaconda3/envs/mujoco_env/lib/python3.8/site-packag

在linux配置mujoco210环境时遇到报错:

[1/1] Cythonizing /root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/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
                       ^
------------------------------------------------------------

/root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/mujoco_py/cymj.pyx:92:23: Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept 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
                     ^
------------------------------------------------------------

/root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/mujoco_py/cymj.pyx:127:21: Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept nogil'
Traceback (most recent call last):
  File "main.py", line 8, in 
    import d4rl
  File "/root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/d4rl/__init__.py", line 14, in 
    import d4rl.locomotion
  File "/root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/d4rl/locomotion/__init__.py", line 2, in 
    from d4rl.locomotion import ant
  File "/root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/d4rl/locomotion/ant.py", line 20, in 
    import mujoco_py
  File "/root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/mujoco_py/__init__.py", line 2, in 
    from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
  File "/root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/mujoco_py/builder.py", line 504, in 
    cymj = load_cython_ext(mujoco_path)
  File "/root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/mujoco_py/builder.py", line 110, in load_cython_ext
    cext_so_path = builder.build()
  File "/root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/mujoco_py/builder.py", line 226, in build
    built_so_file_path = self._build_impl()
  File "/root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/mujoco_py/builder.py", line 278, in _build_impl
    so_file_path = super()._build_impl()
  File "/root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/mujoco_py/builder.py", line 239, in _build_impl
    dist.ext_modules = cythonize([self.extension])
  File "/root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1134, in cythonize
    cythonize_one(*args)
  File "/root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
    raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: /root/anaconda3/envs/mujoco_env/lib/python3.8/site-packages/mujoco_py/cymj.pyx

解决方法:更换Cython版本

pip install Cython==3.0.0a10

你可能感兴趣的:(python,ubuntu)