gym-mujoco2.0安装教程
更新:pip在线安装:
pip install gym[all]==0.10.15 --no-deps mujoco_py
在这之前你需要提前安装好mujoco_py200版本!
这种在线安装会非常舒服,因为可以指定版本,而离线下载指定版本的包比较麻烦!
前言:
openai最近的发展有点诡异,之前做的很多东西现在好像都不怎么更新了,gym都2020年了,还不支持mujoco2.0:
Note that we currently do not support MuJoCo 2.0 and above, so you will need to install a version of mujoco-py which is built for a lower version of MuJoCo like MuJoCo 1.5 (example - mujoco-py-1.50.1.0). As an alternative to mujoco-py, consider PyBullet which uses the open source Bullet physics engine and has no license requirement.
如果你装的是mujoco2.0的话,再安装gym,会显示报错:
安装命令:
pip install gym[all]
Building wheel for mujoco-py (setup.py) ... error
ERROR: Command errored out with exit status 1:
command: /home/lyl/anaconda3/envs/tf14/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l5kt2kcd/mujoco-py/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l5kt2kcd/mujoco-py/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-l7o0w2j0
cwd: /tmp/pip-install-l5kt2kcd/mujoco-py/
Complete output (54 lines):
running bdist_wheel
running build
You appear to be missing MuJoCo. We expected to find the file here: /home/lyl/.mujoco/mjpro150
This package only provides python bindings, the library must be installed separately.
Please follow the instructions on the README to install MuJoCo
https://github.com/openai/mujoco-py#install-mujoco
Which can be downloaded from the website
https://www.roboti.us/index.html
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-l5kt2kcd/mujoco-py/setup.py", line 44, in <module>
tests_require=read_requirements_file('requirements.dev.txt'),
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/site-packages/setuptools/__init__.py", line 165, in setup
return distutils.core.setup(**attrs)
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/site-packages/wheel/bdist_wheel.py", line 223, in run
self.run_command('build')
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip-install-l5kt2kcd/mujoco-py/setup.py", line 28, in run
import mujoco_py # noqa: force build
File "/tmp/pip-install-l5kt2kcd/mujoco-py/mujoco_py/__init__.py", line 3, in <module>
from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
File "/tmp/pip-install-l5kt2kcd/mujoco-py/mujoco_py/builder.py", line 502, in <module>
mjpro_path, key_path = discover_mujoco()
File "/tmp/pip-install-l5kt2kcd/mujoco-py/mujoco_py/utils.py", line 93, in discover_mujoco
raise Exception(message)
Exception:
You appear to be missing MuJoCo. We expected to find the file here: /home/lyl/.mujoco/mjpro150
This package only provides python bindings, the library must be installed separately.
Please follow the instructions on the README to install MuJoCo
https://github.com/openai/mujoco-py#install-mujoco
Which can be downloaded from the website
https://www.roboti.us/index.html
----------------------------------------
ERROR: Failed building wheel for mujoco-py
Running setup.py clean for mujoco-py
Failed to build mujoco-py
Installing collected packages: mujoco-py
Attempting uninstall: mujoco-py
Found existing installation: mujoco-py 2.0.2.5
Uninstalling mujoco-py-2.0.2.5:
Successfully uninstalled mujoco-py-2.0.2.5
Running setup.py install for mujoco-py ... error
ERROR: Command errored out with exit status 1:
command: /home/lyl/anaconda3/envs/tf14/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l5kt2kcd/mujoco-py/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l5kt2kcd/mujoco-py/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-batt1h17/install-record.txt --single-version-externally-managed --compile --install-headers /home/lyl/anaconda3/envs/tf14/include/python3.6m/mujoco-py
cwd: /tmp/pip-install-l5kt2kcd/mujoco-py/
Complete output (56 lines):
running install
running build
You appear to be missing MuJoCo. We expected to find the file here: /home/lyl/.mujoco/mjpro150
This package only provides python bindings, the library must be installed separately.
Please follow the instructions on the README to install MuJoCo
https://github.com/openai/mujoco-py#install-mujoco
Which can be downloaded from the website
https://www.roboti.us/index.html
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-install-l5kt2kcd/mujoco-py/setup.py", line 44, in <module>
tests_require=read_requirements_file('requirements.dev.txt'),
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/site-packages/setuptools/__init__.py", line 165, in setup
return distutils.core.setup(**attrs)
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/distutils/core.py", line 148, in setup
dist.run_commands()
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/distutils/dist.py", line 955, in run_commands
self.run_command(cmd)
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/site-packages/setuptools/command/install.py", line 61, in run
return orig.install.run(self)
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/distutils/command/install.py", line 545, in run
self.run_command('build')
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/distutils/cmd.py", line 313, in run_command
self.distribution.run_command(command)
File "/home/lyl/anaconda3/envs/tf14/lib/python3.6/distutils/dist.py", line 974, in run_command
cmd_obj.run()
File "/tmp/pip-install-l5kt2kcd/mujoco-py/setup.py", line 28, in run
import mujoco_py # noqa: force build
File "/tmp/pip-install-l5kt2kcd/mujoco-py/mujoco_py/__init__.py", line 3, in <module>
from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
File "/tmp/pip-install-l5kt2kcd/mujoco-py/mujoco_py/builder.py", line 502, in <module>
mjpro_path, key_path = discover_mujoco()
File "/tmp/pip-install-l5kt2kcd/mujoco-py/mujoco_py/utils.py", line 93, in discover_mujoco
raise Exception(message)
Exception:
You appear to be missing MuJoCo. We expected to find the file here: /home/lyl/.mujoco/mjpro150
This package only provides python bindings, the library must be installed separately.
Please follow the instructions on the README to install MuJoCo
https://github.com/openai/mujoco-py#install-mujoco
Which can be downloaded from the website
https://www.roboti.us/index.html
----------------------------------------
Rolling back uninstall of mujoco-py
Moving to /home/lyl/anaconda3/envs/tf14/lib/python3.6/site-packages/mujoco_py-2.0.2.5-py3.6.egg
from /home/lyl/anaconda3/envs/tf14/lib/python3.6/site-packages/~ujoco_py-2.0.2.5-py3.6.egg
ERROR: Command errored out with exit status 1: /home/lyl/anaconda3/envs/tf14/bin/python -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-l5kt2kcd/mujoco-py/setup.py'"'"'; __file__='"'"'/tmp/pip-install-l5kt2kcd/mujoco-py/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-batt1h17/install-record.txt --single-version-externally-managed --compile --install-headers /home/lyl/anaconda3/envs/tf14/include/python3.6m/mujoco-py Check the logs for full command output.
但是呢,你可以下载gym的库文件,通过python setup.py install 来安装:
去官网下载:
https://github.com/openai/gym/archive/master.zip
解压;
进入目录,修改setup.py文件;
删除对mujoco相关的版本依赖;
# Environment-specific dependencies.
extras = {
'atari': ['atari_py~=0.2.0', 'Pillow', 'opencv-python'],
'box2d': ['box2d-py~=2.3.5'],
'classic_control': [],
# 'mujoco': ['mujoco_py>=1.50, <2.0', 'imageio'],
# 'robotics': ['mujoco_py>=1.50, <2.0', 'imageio'],
}
python setup.py install
直接结束,可以使用gym里面调用mujoco相关的环境了~