我试着在新的macOs大苏尔上运行这个简单的健身房例子。
import gym
env = gym.make('CartPole-v0')
env.reset()
for _ in range(1000):
env.render()
env.step(env.action_space.sample()) # take a random action
env.close()但是,我遇到了这个
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gym/envs/classic_control/rendering.py", line 25, in <module>
from pyglet.gl import *
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyglet/gl/__init__.py", line 95, in <module>
from pyglet.gl.lib import GLException
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyglet/gl/lib.py", line 147, in <module>
from pyglet.gl.lib_agl import link_GL, link_GLU, link_AGL
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyglet/gl/lib_agl.py", line 43, in <module>
gl_lib = pyglet.lib.load_library(framework='/System/Library/Frameworks/OpenGL.framework')
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyglet/lib.py", line 124, in load_library
return self.load_framework(kwargs['framework'])
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyglet/lib.py", line 279, in load_framework
raise ImportError("Can't find framework %s." % path)
ImportError: Can't find framework /System/Library/Frameworks/OpenGL.framework.
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/.../myFileName.py", line 19, in <module>
env.render()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gym/core.py", line 240, in render
return self.env.render(mode, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gym/envs/classic_control/cartpole.py", line 174, in render
from gym.envs.classic_control import rendering
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/gym/envs/classic_control/rendering.py", line 32, in <module>
''')
ImportError:
Error occurred while running `from pyglet.gl import *`
HINT: make sure you have OpenGL install. On Ubuntu, you can run 'apt-get install python-opengl'.
If you're running on a server, you may need a virtual frame buffer; something like this should work:
'xvfb-run -s "-screen 0 1400x900x24" python <your_script.py>'我跟踪了这和这的讨论,但没有找到一个可行的解决方案。有人能帮忙吗?
附加信息
pip install pyglet==1.5.11之后,它显示了Requirement already satisfied: pyglet==1.5.11 in /Library/Frameworks/...,但是,在我的脚本中运行print(pyglet.version)时,我得到了1.5.0)。即使1.5.11已经安装,我如何才能将它更改为它呢?发布于 2020-12-26 02:27:28
试试pip安装pyglet==1.5.11
发布于 2021-01-27 08:04:00
我有macOS大Sur 11.1和Pychram CE 2020.3
然后,我从Python解释器中安装了pyglet1.5.14。值得一提的是
pip安装pyglet==1.5.14
没有解决错误,但是Python解释器的pyglet 1.5.14工作了。
https://stackoverflow.com/questions/65173684
复制相似问题