目录
问题描述
解决方案
参考链接
后续错误及解决方案补充
错误 1
解决方案 1
错误 2
解决方案 2
(stable_baseline) lily@lily-System-Product-Name:~/code/stable-baselines3$ python test_SAC.py
Compiling /home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/mujoco_py-2.1.2.14-py3.7.egg/mujoco_py/cymj.pyx because it changed.
[1/1] Cythonizing /home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/mujoco_py-2.1.2.14-py3.7.egg/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/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/mujoco_py-2.1.2.14-py3.7.egg/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/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/mujoco_py-2.1.2.14-py3.7.egg/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'.
Traceback (most recent call last):
File "test_SAC.py", line 7, in
from envs.halfcheetah_forward_backward import HalfCheetahForwardBackwardEnv
File "/home/lily/code/stable-baselines3/envs/halfcheetah_forward_backward.py", line 8, in
from gym.envs.mujoco.mujoco_env import MujocoEnv
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/gym/envs/mujoco/__init__.py", line 1, in
from gym.envs.mujoco.mujoco_env import MujocoEnv, MuJocoPyEnv # isort:skip
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/gym/envs/mujoco/mujoco_env.py", line 16, in
import mujoco_py
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/mujoco_py-2.1.2.14-py3.7.egg/mujoco_py/__init__.py", line 2, in
from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/mujoco_py-2.1.2.14-py3.7.egg/mujoco_py/builder.py", line 504, in
cymj = load_cython_ext(mujoco_path)
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/mujoco_py-2.1.2.14-py3.7.egg/mujoco_py/builder.py", line 110, in load_cython_ext
cext_so_path = builder.build()
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/mujoco_py-2.1.2.14-py3.7.egg/mujoco_py/builder.py", line 226, in build
built_so_file_path = self._build_impl()
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/mujoco_py-2.1.2.14-py3.7.egg/mujoco_py/builder.py", line 296, in _build_impl
so_file_path = super()._build_impl()
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/mujoco_py-2.1.2.14-py3.7.egg/mujoco_py/builder.py", line 239, in _build_impl
dist.ext_modules = cythonize([self.extension])
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1134, in cythonize
cythonize_one(*args)
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/Cython/Build/Dependencies.py", line 1301, in cythonize_one
raise CompileError(None, pyx_file)
Cython.Compiler.Errors.CompileError: /home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/mujoco_py-2.1.2.14-py3.7.egg/mujoco_py/cymj.pyx
(stable_baseline) webw6@ubuntu:~$ gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
自己电脑上的
(TDEOC) lily@lily-System-Product-Name:~/code/stable-baselines3$ conda activate stable_baseline
(stable_baseline) lily@lily-System-Product-Name:~/code/stable-baselines3$ pip list
Package Version
----------------------------- ------------
alabaster 0.7.13
Babel 2.12.1
backcall 0.2.0
certifi 2022.12.7
cffi 1.15.1
charset-normalizer 3.2.0
cloudpickle 2.2.1
cycler 0.11.0
Cython 3.0.2
decorator 5.1.1
docutils 0.18.1
exceptiongroup 1.1.3
Farama-Notifications 0.0.4
fasteners 0.18
fonttools 4.38.0
glfw 2.6.2
gym 0.25.2
gym-notices 0.0.8
gymnasium 0.28.1
idna 3.4
ImageHash 4.3.1
imageio 2.31.2
imagesize 1.4.1
importlib-metadata 6.7.0
iniconfig 2.0.0
ipdb 0.13.13
ipython 7.34.0
jax-jumpy 1.0.0
jedi 0.19.0
Jinja2 3.1.2
kiwisolver 1.4.5
MarkupSafe 2.1.3
matplotlib 3.5.3
matplotlib-inline 0.1.6
mujoco-py 2.1.2.14
numpy 1.21.6
numpydoc 1.5.0
packaging 23.1
pandas 1.3.5
parso 0.8.3
pexpect 4.8.0
pickleshare 0.7.5
Pillow 9.5.0
pip 22.3.1
pluggy 1.2.0
prompt-toolkit 3.0.39
ptyprocess 0.7.0
pycparser 2.21
Pygments 2.16.1
pyparsing 3.1.1
pytest 7.4.0
pytest-instafail 0.3.0
python-dateutil 2.8.2
pytz 2023.3
PyWavelets 1.3.0
requests 2.31.0
scipy 1.7.3
setuptools 65.6.3
six 1.16.0
snowballstemmer 2.2.0
Sphinx 5.3.0
sphinx-rtd-theme 1.3.0
sphinxcontrib-applehelp 1.0.2
sphinxcontrib-devhelp 1.0.2
sphinxcontrib-htmlhelp 2.0.0
sphinxcontrib-jquery 4.1
sphinxcontrib-jsmath 1.0.1
sphinxcontrib-qthelp 1.0.3
sphinxcontrib-serializinghtml 1.1.5
stable-baselines3 2.0.0
tomli 2.0.1
torch 1.11.0+cu113
torchaudio 0.11.0+cu113
torchvision 0.12.0+cu113
traitlets 5.9.0
typing_extensions 4.7.1
urllib3 2.0.4
wcwidth 0.2.6
wheel 0.38.4
zipp 3.15.0
服务器上的版本
absl-py 1.4.0
aiohttp 3.8.5
aiosignal 1.3.1
ale-py 0.7.4
argcomplete 3.1.1
async-timeout 4.0.2
asynctest 0.13.0
attrs 23.1.0
AutoROM 0.4.2
AutoROM.accept-rom-license 0.5.5
blessed 1.20.0
boto 2.49.0
cachetools 5.3.0
certifi 2022.12.7
cffi 1.15.1
charset-normalizer 3.1.0
cherry-rl 0.1.4
click 8.1.3
cloudpickle 2.2.1
crcmod 1.7
cryptography 41.0.3
cycler 0.11.0
Cython 0.29.34
Farama-Notifications 0.0.4
fasteners 0.18
fonttools 4.38.0
frozenlist 1.3.3
gcs-oauth2-boto-plugin 3.0
glfw 2.5.9
google-apitools 0.5.32
google-auth 2.16.2
google-auth-oauthlib 0.4.6
google-reauth 0.1.1
gpustat 1.1
grpcio 1.51.3
gsutil 5.25
gym 0.21.0
gymnasium 0.28.1
httplib2 0.20.4
idna 3.4
imageio 2.27.0
importlib-metadata 4.13.0
importlib-resources 5.12.0
install 1.3.5
jax-jumpy 1.0.0
kiwisolver 1.4.4
learn2learn 0.1.7
libtorrent 2.0.7
Markdown 3.4.1
markdown-it-py 2.2.0
MarkupSafe 2.1.2
matplotlib 3.5.3
mdurl 0.1.2
monotonic 1.6
mujoco-py 2.1.2.14
multidict 6.0.4
numpy 1.21.6
nvidia-ml-py 11.525.112
oauth2client 4.1.3
oauthlib 3.2.2
opencv-python 4.7.0.72
packaging 23.0
pandas 1.3.5
Pillow 9.5.0
pip 22.3.1
protobuf 3.20.3
psutil 5.9.4
pyasn1 0.4.8
pyasn1-modules 0.2.8
pycparser 2.21
Pygments 2.14.0
pyOpenSSL 23.2.0
pyparsing 3.0.9
python-dateutil 2.8.2
pytz 2022.7.1
pyu2f 0.1.5
qpth 0.0.15
requests 2.28.2
requests-oauthlib 1.3.1
retry-decorator 1.1.1
rich 13.3.2
rsa 4.7.2
sb3-contrib 2.0.0
scipy 1.7.3
setuptools 65.6.3
Shimmy 1.1.0
six 1.16.0
stable-baselines3 2.0.0
tensorboard 2.11.2
tensorboard-data-server 0.6.1
tensorboard-plugin-wit 1.8.1
torch 1.11.0+cu113
torchaudio 0.11.0+cu113
torchvision 0.12.0+cu113
tqdm 4.65.0
typing_extensions 4.5.0
urllib3 1.26.15
wcwidth 0.2.6
Werkzeug 2.2.3
wheel 0.38.4
yarl 1.9.2
zipp 3.15.0
pip install "cython<3"
https://github.com/openai/mujoco-py/issues/773
当gym==0.25.2
(stable_baseline) lily@lily-System-Product-Name:~/code/stable-baselines3$ python test_SAC.py
Traceback (most recent call last):
File "test_SAC.py", line 7, in
from envs.halfcheetah_forward_backward import HalfCheetahForwardBackwardEnv
File "/home/lily/code/stable-baselines3/envs/halfcheetah_forward_backward.py", line 8, in
from gym.envs.mujoco.mujoco_env import MujocoEnv
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/gym/envs/mujoco/__init__.py", line 2, in
from gym.envs.mujoco.mujoco_rendering import ( # isort:skip
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/gym/envs/mujoco/mujoco_rendering.py", line 8, in
import mujoco
ModuleNotFoundError: No module named 'mujoco'
当gym==0.21.0
(stable_baseline) lily@lily-System-Product-Name:~/code/stable-baselines3$ python test_SAC.py
Traceback (most recent call last):
File "test_SAC.py", line 1, in
import gym
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/gym/__init__.py", line 13, in
from gym.envs import make, spec, register
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/gym/envs/__init__.py", line 10, in
_load_env_plugins()
File "/home/lily/software/anaconda3/envs/stable_baseline/lib/python3.7/site-packages/gym/envs/registration.py", line 250, in load_env_plugins
for plugin in metadata.entry_points().get(entry_point, []):
AttributeError: 'EntryPoints' object has no attribute 'get'
importlib-metadata==4.13.0
当想安装mujoco-py 2.0.x.x时,发现及时令pip install "cython<3"也还是会有相同的错误。
此时可以执行
pip install mujoco_py==2.0.2.5
即可完美解决。