使用mujoco为MuJoCo物理库绑定Python
我想使用MuJoCo(http://www.mujoco.org/),一个使用python绑定的高级物理模拟器(https://github.com/openai/mujoco-py)。
我有我的MuJoCo许可证文件mjkey.text,并相应地将所需的路径MUJOCO_PY_MJKEY_PATH,MUJOCO_PY_MJPRO_PATH添加到环境变量中。
MUJOCO_PY_MJPRO_PATH = C:DropboxPhDMuJoComjpro131
MUJOCO_PY_MJKEY_PATH = C:DropboxPhDMuJoComjpro131bin
但是,只要我想用下面的简单代码导入libray,
import mujoco_py
我收到以下错误消息。
C:DropboxPythonAnacondapython.exe
C:/Dropbox/PhD/Python/X/MujocoHelloWorld/test.py
Traceback (most recent call last):
File "C:/Dropbox/PhD/Python/X/MujocoHelloWorld/test.py", line 1, in <module>
import mujoco_py
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "C:DropboxPythonAnacondalibsite-packagesmujoco_py-0.5.4-py3.5.eggmujoco_py__init__.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "C:DropboxPythonAnacondalibsite-packagesmujoco_py-0.5.4-py3.5.eggmujoco_pymjviewer.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "C:DropboxPythonAnacondalibsite-packagesmujoco_py-0.5.4-py3.5.eggmujoco_pymjcore.py", line 6, in <module>
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "C:DropboxPythonAnacondalibsite-packagesmujoco_py-0.5.4-py3.5.eggmujoco_pymjlib.py", line 21, in <module>
File "C:DropboxPythonAnacondalibctypes__init__.py", line 425, in LoadLibrary
return self._dlltype(name)
File "C:DropboxPythonAnacondalibctypes__init__.py", line 347, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 193] %1 is not a valid Win32 application
Process finished with exit code 1
我在使用MuJoCo 1.31 64位的Windows 7 64位上使用Python 3.5.1 64位。
我猜想这个问题是由于某种不兼容性的原因,我还尝试使用32位MuJoCo 1.31的Python 3.5.2 32位。 甚至,我尝试了非逻辑的32位Python和64位的MuJoCo组合,反之亦然。
MuJoCo库中已编译的示例“simulate.exe”非常完美。 所以,我想我的64位MuJoCo库没有问题。 (顺便说一句,它的32位版本不能在64位Windows上运行)
因此,将C ++库加载到Python时可能会出现问题。 我进行了调试,至少检查了mujoco_py库中的Python代码尝试从正确的路径加载“mujoco131.lib”(不是“mujoco131.dll”)。 然后发生错误,代码无法进一步运行。
我愿意接受任何意见和建议。
干杯! 祝你有愉快的一天!
尝试编辑mjlib.py
,用加载器中的"bin/mujoco131.dll"
替换"bin/mujoco131.lib"
。
我还必须在platname_targdir.py
明确指定platname = "win"