gpt4 book ai didi

使用 mujoco-py 包的 MuJoCo 物理库的 Python 绑定(bind)

转载 作者:太空狗 更新时间:2023-10-29 21:02:55 24 4
gpt4 key购买 nike

我想使用 MuJoCo ( http://www.mujoco.org/ ),一个带有 python 绑定(bind)的高级物理模拟器 ( https://github.com/openai/mujoco-py )。

我有我的 MuJoCo 许可证文件 mjkey.text 并相应地将所需路径 MUJOCO_PY_MJKEY_PATH、MUJOCO_PY_MJPRO_PATH 添加到环境变量。

MUJOCO_PY_MJPRO_PATH = C:\Dropbox\PhD\MuJoCo\mjpro131
MUJOCO_PY_MJKEY_PATH = C:\Dropbox\PhD\MuJoCo\mjpro131\bin

但是,一旦我想使用以下简单代码导入库,

import mujoco_py

我收到以下错误消息。

C:\Dropbox\Python\Anaconda\python.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:\Dropbox\Python\Anaconda\lib\site-packages\mujoco_py-0.5.4-py3.5.egg\mujoco_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:\Dropbox\Python\Anaconda\lib\site-packages\mujoco_py-0.5.4-py3.5.egg\mujoco_py\mjviewer.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:\Dropbox\Python\Anaconda\lib\site-packages\mujoco_py-0.5.4-py3.5.egg\mujoco_py\mjcore.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:\Dropbox\Python\Anaconda\lib\site-packages\mujoco_py-0.5.4-py3.5.egg\mujoco_py\mjlib.py", line 21, in <module>
File "C:\Dropbox\Python\Anaconda\lib\ctypes\__init__.py", line 425, in LoadLibrary
return self._dlltype(name)
File "C:\Dropbox\Python\Anaconda\lib\ctypes\__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

我在 Windows 7 64 位和 MuJoCo 1.31 64 位上使用 Python 3.5.1 64 位。

我猜问题是由于某种不兼容造成的,我还尝试了 Python 3.5.2 32 位和 MuJoCo 1.31 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.lib" 替换为 "bin/mujoco131.dll"

我还必须在 platname_targdir.py 中明确指定 platname = "win"

关于使用 mujoco-py 包的 MuJoCo 物理库的 Python 绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38766267/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com