【问题标题】:ImportError: Can't find framework /System/Library/Frameworks/OpenGL.frameworkImportError:找不到框架/System/Library/Frameworks/OpenGL.framework
【发布时间】:2021-03-18 06:49:56
【问题描述】:

我正在尝试在新的 macOs Big Sur 上运行这个简单的健身房示例。

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>'

我关注了thisthis 的讨论,但找不到可行的解决方案。 有人可以帮忙吗?


其他信息

  • macOs 大苏尔 11.0.1
  • Python 3.9.0
  • PyOpenGL==3.1.5
  • pyglet==1.5.11(运行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

【问题讨论】:

标签: python pyglet openai-gym macos-big-sur openai


【解决方案1】:

尝试pip install pyglet==1.5.11

来源 - https://github.com/openai/gym/issues/2101

【讨论】:

  • 这会引发关于与 OpenAI 健身房模块兼容性的奇怪警告,但仍然可以为我启动健身房环境。
  • 我刚刚安装了最新的 pyglet 强制版本 (pip install pyglet==1.5.15)。正如@Tim 所说,您会收到一个依赖警告(错误:pip 的依赖解析器当前未考虑所有已安装的软件包。此行为是以下依赖冲突的根源。gym 0.18.0 需要 pyglet=1.4.0,但你有不兼容的 pyglet 1.5.15。),但我成功地在运行 macOS Big Sur 11.2.3 的 Mac 上获得了 Open AI 健身房环境渲染。
【解决方案2】:

我有 macOS Big Sur 11.1 和 Pychram CE 2020.3 与

  1. Python 3.7
  2. Tensorflow 1.14.0(用于 A2C)
  3. PyOpenGL 3.1.5
  4. 健身房 0.17.3
  5. Pyglet 1.5.14

然后我从 Python Interpreter 安装了 pyglet 1.5.14。 值得一提的是

pip install pyglet==1.5.14

没有解决错误,但 Python Interpreter 的 pyglet 1.5.14 工作正常。

【讨论】:

  • 谢谢,但是 Python Interpreter 中的 pyglet 是什么意思?
猜你喜欢
  • 2014-08-07
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-15
  • 2021-04-28
  • 2016-05-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多