Error occurred while running `from pyglet.gl import *` 해결하기

2021. 9. 8. 23:34꿀팁 분석 환경 설정/파이썬 개발 팁

<ipython-input-4-f1e8f42adf6c> in get_screen()
     12     # Returned screen requested by gym is 400x600x3, but is sometimes larger
     13     # such as 800x1200x3. Transpose it into torch order (CHW).
---> 14     screen = env.render(mode='rgb_array').transpose((2, 0, 1))
     15     # Cart is in the lower half, so strip off the top and bottom of the screen
     16     _, screen_height, screen_width = screen.shape

/opt/conda/lib/python3.8/site-packages/gym/envs/classic_control/cartpole.py in render(self, mode)
    177 
    178         if self.viewer is None:
--> 179             from gym.envs.classic_control import rendering
    180 
    181             self.viewer = rendering.Viewer(screen_width, screen_height)

/opt/conda/lib/python3.8/site-packages/gym/envs/classic_control/rendering.py in <module>
     27     from pyglet.gl import *
     28 except ImportError as e:
---> 29     raise ImportError(
     30         """
     31     Error occurred while running `from pyglet.gl import *`

ImportError: 
    Error occurred while running `from pyglet.gl import *`
    HINT: make sure you have OpenGL installed. 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>'

해결 방법

 sudo apt-get update -y
 sudo apt-get install -y python-opengl
728x90