mujoco-py
mujoco-py copied to clipboard
Mujoco-py is incompatible with cython 3 (Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept nogil)
Describe the bug
Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept nogil'
To Reproduce Install cpython 3.0.0, import mujoco-py
Expected behavior mujoco-py compiles
Error Messages From gymnasium's CI
tests/wrappers/test_passive_env_checker.py:9: in <module>
from tests.envs.test_envs import PASSIVE_CHECK_IGNORE_WARNING
<frozen importlib._bootstrap>:991: in _find_and_load
???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
???
<frozen importlib._bootstrap>:671: in _load_unlocked
???
../lib/python3.8/site-packages/_pytest/assertion/rewrite.py:168: in exec_module
exec(co, module.__dict__)
tests/envs/test_envs.py:10: in <module>
from tests.envs.utils import (
tests/envs/utils.py:34: in <module>
all_testing_initialised_envs: List[Optional[gym.Env]] = [
tests/envs/utils.py:35: in <listcomp>
try_make_env(env_spec) for env_spec in gym.envs.registry.values()
tests/envs/utils.py:22: in try_make_env
return env_spec.make(disable_env_checker=True).unwrapped
gymnasium/envs/registration.py:130: in make
return make(self, **kwargs)
gymnasium/envs/registration.py:756: in make
env_creator = load_env_creator(env_spec.entry_point)
gymnasium/envs/registration.py:545: in load_env_creator
mod = importlib.import_module(mod_name)
../lib/python3.8/importlib/__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
gymnasium/envs/mujoco/__init__.py:1: in <module>
from gymnasium.envs.mujoco.mujoco_env import MujocoEnv, MuJocoPyEnv # isort:skip
gymnasium/envs/mujoco/mujoco_env.py:13: in <module>
import mujoco_py
/mujoco-py/mujoco_py/__init__.py:2: in <module>
from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
/mujoco-py/mujoco_py/builder.py:504: in <module>
cymj = load_cython_ext(mujoco_path)
/mujoco-py/mujoco_py/builder.py:110: in load_cython_ext
cext_so_path = builder.build()
/mujoco-py/mujoco_py/builder.py:226: in build
built_so_file_path = self._build_impl()
/mujoco-py/mujoco_py/builder.py:278: in _build_impl
so_file_path = super()._build_impl()
/mujoco-py/mujoco_py/builder.py:239: in _build_impl
dist.ext_modules = cythonize([self.extension])
../lib/python3.8/site-packages/Cython/Build/Dependencies.py:1134: in cythonize
cythonize_one(*args)
../lib/python3.8/site-packages/Cython/Build/Dependencies.py:1301: in cythonize_one
raise CompileError(None, pyx_file)
E Cython.Compiler.Errors.CompileError: /mujoco-py/mujoco_py/cymj.pyx
------------------------------- Captured stdout --------------------------------
Compiling /mujoco-py/mujoco_py/cymj.pyx because it changed.
[1/1] Cythonizing /mujoco-py/mujoco_py/cymj.pyx
------------------------------- Captured stderr --------------------------------
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
^
------------------------------------------------------------
/mujoco-py/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
^
------------------------------------------------------------
/mujoco-py/mujoco_py/cymj.pyx:127:21: Cannot assign type 'void (const char *) except * nogil' to 'void (*)(const char *) noexcept nogil'
Facing the same issue.
Same issue on my side
I solved it with pip install "cython<3"
Same issue on my side
Same
TYSM for figuring this out, wasted 3 hours today
TYSM for figuring this out, wasted 3 hours today
4 hours and 5 times recreate virtual environments 😇
already have Cython==0.29.36 but the same error exists when pip install mujoco_py==2.0.2.7
already have Cython==0.29.36 but the same error exists when pip install mujoco_py==2.0.2.7
Same
I am using mujoco-py==1.50.1.68
I cannot tell if this is directly related to cython 3 or not. I have 0.29.36 installed (and I've tried many versions from 0.27.2 on up) and the same error is occurring even on mujoco_py==2.0.2.13. I tried to determine if a patch to the underlying c++ compiler was at fault, but that does not seem to be the case.
I cannot tell if this is directly related to cython 3 or not. I have 0.29.36 installed (and I've tried many versions from 0.27.2 on up) and the same error is occurring even on mujoco_py==2.0.2.13. I tried to determine if a patch to the underlying c++ compiler was at fault, but that does not seem to be the case.
I would be surprised as our CI should be failing if this was true but it is not failing with cython < 3 also if you are getting the same issue with nogil in the error then this is a cython >= 3 thing
I would be surprised as our CI should be failing if this was true but it is not failing with cython < 3 also if you are getting the same issue with
nogilin the error then this is acython >= 3thing
I now have it working with mujoco_py==2.0.2.5, but no later 2.0.2.x releases. I see that 2.0.2.5 is probably the last "official" 2.0.2 release, but PyPi is misleading.
I was able to use
pip install 'cython<3'
to compile mujoco-py 2.1.2.14 on Ubuntu 22.04, Python 3.8
same, cython<3 not works for me
I was facing the similar issue in numpy-1.23.3 build with cython 3.0.0, using pip3 install "cython<3" worked for me.
I solved it with
pip install "cython<3"
Does not work for me, I am trying to install safety-gym.
mujoco200 mujoco-py 2.1.2.14 Ubuntu 20.04 Python 3.6
Anyone found any other ways to resolve?
TIA
What is your current Cython version?
What is your current Cython version?
Cython 0.29.36
can you try updating your python to a higher version like 3.8.
can you try updating your python to a higher version like 3.8.
No progress.
I would be surprised as our CI should be failing if this was true but it is not failing with cython < 3 also if you are getting the same issue with
nogilin the error then this is acython >= 3thingI now have it working with
mujoco_py==2.0.2.5, but no later2.0.2.xreleases. I see that 2.0.2.5 is probably the last "official" 2.0.2 release, but PyPi is misleading.
This Worked!
Surprisingly, uninstalling Cython fixed the problem for me.
Python: 3.8 gymnasium==0.29.1 mujoco==2.3.7
Mujoco version: 2.10
- Add a compiler directive " compiler_directives={'legacy_implicit_noexcept': True}" to the line 239 of mujoco_py/builder.py
def _build_impl(self):
dist = Distribution({
"script_name": None,
"script_args": ["build_ext"]
})
dist.ext_modules = cythonize([self.extension],compiler_directives={'legacy_implicit_noexcept': True})
- Update Cython to the latest 3.0.2 version.
pip install -U Cython
- The reasons can be found here https://github.com/scikit-learn/scikit-learn/issues/25609 https://github.com/cython/cython/issues/5637
I would be surprised as our CI should be failing if this was true but it is not failing with cython < 3 also if you are getting the same issue with
nogilin the error then this is acython >= 3thingI now have it working with
mujoco_py==2.0.2.5, but no later2.0.2.xreleases. I see that 2.0.2.5 is probably the last "official" 2.0.2 release, but PyPi is misleading.This Worked!
It works for my.
I am use mujoco210 and mujoco_py==2.1.2.14
This command helps for the cymj error:
I solved it with
pip install "cython<3"
Thanks!
I solved it with
pip install "cython<3"Does not work for me, I am trying to install safety-gym.
mujoco200 mujoco-py 2.1.2.14 Ubuntu 20.04 Python 3.6
Anyone found any other ways to resolve?
TIA
mujoco-py 2.1.2.14 and mujoco200 are not match. Use mujoco_py 2.1.2.14 with mujoco210, or mujoco>2.0 <2.1 with mujoco200.
- Add a compiler directive " compiler_directives={'legacy_implicit_noexcept': True}" to the line 239 of mujoco_py/builder.py
def _build_impl(self): dist = Distribution({ "script_name": None, "script_args": ["build_ext"] }) dist.ext_modules = cythonize([self.extension],compiler_directives={'legacy_implicit_noexcept': True})
- Update Cython to the latest 3.0.2 version.
pip install -U Cython
This works for my problem. Thanks a lot.
my env:
- Ubuntu 22.04
- python 3.8
- mujoco 2.1.0
- mujoco-py 2.1.2.14
- Cython 3.0.6
- Add a compiler directive " compiler_directives={'legacy_implicit_noexcept': True}" to the line 239 of mujoco_py/builder.py
def _build_impl(self): dist = Distribution({ "script_name": None, "script_args": ["build_ext"] }) dist.ext_modules = cythonize([self.extension],compiler_directives={'legacy_implicit_noexcept': True})
- Update Cython to the latest 3.0.2 version.
pip install -U CythonThis works for my problem. Thanks a lot.
my env:
- Ubuntu 22.04
- python 3.8
- mujoco 2.1.0
- mujoco-py 2.1.2.14
- Cython 3.0.6
This works! Thanks
pip install Cython==3.0.0a10 works for me.
My env: Ubuntu 20.04 python 3.8.17 mujoco 2.1.0 mujoco-py 2.1.2.14