opengl 名称错误:未定义名称'glPushMatrix'

5kgi1eie  于 2022-11-23  发布在  其他
关注(0)|答案(1)|浏览(500)

尝试运行稳定的基线健身房测试代码

import gym

from stable_baselines3 import A2C

env = gym.make("CartPole-v1")

model = A2C("MlpPolicy", env, verbose=1)
model.learn(total_timesteps=10_000)

obs = env.reset()
for i in range(100):
    action, _state = model.predict(obs, deterministic=True)
    obs, reward, done, info = env.step(action)
    env.render()
    if done:
      obs = env.reset()

发现错误“名称错误:未定义名称'glPushMatrix'”

Traceback (most recent call last):
  File "test_cart_pole.py", line 14, in <module>
    env.render()
  File "/Users/xxx/opt/anaconda3/lib/python3.8/site-packages/gym/core.py", line 295, in render
    return self.env.render(mode, **kwargs)
  File "/Users/xxx/opt/anaconda3/lib/python3.8/site-packages/gym/envs/classic_control/cartpole.py", line 229, in render
    return self.viewer.render(return_rgb_array=mode == "rgb_array")
  File "/Users/xxx/opt/anaconda3/lib/python3.8/site-packages/gym/envs/classic_control/rendering.py", line 126, in render
    self.transform.enable()
  File "/Users/xxx/opt/anaconda3/lib/python3.8/site-packages/gym/envs/classic_control/rendering.py", line 232, in enable
    glPushMatrix()
NameError: name 'glPushMatrix' is not defined

我尝试了“pip安装PyOpenGL PyOpenGL_accelerate”,它也没有帮助卸载pyglet并再次安装,没有工作太任何想法???

2j4z5cfb

2j4z5cfb1#

只是遇到了同样的问题。通过安装旧版本的pyglet修复了它:

$ pip install pyglet==1.5.27

我不知道这是否是最新版本,避免了这个问题,但它的工作。

相关问题