Env.render() not working on Jupyter

Hello,
I installed Anaconda and downloaded some code.
It´s the classic OpenAI project, in this case Getting Started With OpenAI Gym | Paperspace Blog
However, when I type

env.render(mode = “human”)

It says (see below).
The same happens in a different computer with a fresh Anaconda installation:


ImportError Traceback (most recent call last)
File /opt/anaconda3/lib/python3.9/site-packages/gym/envs/classic_control/rendering.py:25, in
24 try:
—> 25 from pyglet.gl import *
26 except ImportError as e:

File /opt/anaconda3/lib/python3.9/site-packages/pyglet/gl/init.py:95, in
36 “”“OpenGL and GLU interface.
37
38 This package imports all OpenGL, GLU and registered OpenGL extension
(…)
92 below.
93 “””
—> 95 from pyglet.gl.lib import GLException
96 from pyglet.gl.gl import *

File /opt/anaconda3/lib/python3.9/site-packages/pyglet/gl/lib.py:147, in
146 elif pyglet.compat_platform == ‘darwin’:
→ 147 from pyglet.gl.lib_agl import link_GL, link_GLU, link_AGL
148 else:

File /opt/anaconda3/lib/python3.9/site-packages/pyglet/gl/lib_agl.py:43, in
41 all = [‘link_GL’, ‘link_GLU’, ‘link_AGL’]
—> 43 gl_lib = pyglet.lib.load_library(framework=‘/System/Library/Frameworks/OpenGL.framework’)
44 agl_lib = pyglet.lib.load_library(framework=‘/System/Library/Frameworks/AGL.framework’)

File /opt/anaconda3/lib/python3.9/site-packages/pyglet/lib.py:124, in LibraryLoader.load_library(self, *names, **kwargs)
123 if ‘framework’ in kwargs and self.platform == ‘darwin’:
→ 124 return self.load_framework(kwargs[‘framework’])
126 if not names:

File /opt/anaconda3/lib/python3.9/site-packages/pyglet/lib.py:279, in MachOLibraryLoader.load_framework(self, path)
277 return lib
→ 279 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:

ImportError Traceback (most recent call last)
Input In [4], in <cell line: 1>()
----> 1 env.render(mode = “human”)

File /opt/anaconda3/lib/python3.9/site-packages/gym/core.py:240, in Wrapper.render(self, mode, **kwargs)
239 def render(self, mode=‘human’, **kwargs):
→ 240 return self.env.render(mode, **kwargs)

File /opt/anaconda3/lib/python3.9/site-packages/gym/envs/classic_control/mountain_car.py:126, in MountainCarEnv.render(self, mode)
123 carheight = 20
125 if self.viewer is None:
→ 126 from gym.envs.classic_control import rendering
127 self.viewer = rendering.Viewer(screen_width, screen_height)
128 xs = np.linspace(self.min_position, self.max_position, 100)

File /opt/anaconda3/lib/python3.9/site-packages/gym/envs/classic_control/rendering.py:27, in
25 from pyglet.gl import *
26 except ImportError as e:
—> 27 raise ImportError(‘’’
28 Error occurred while running from pyglet.gl import *
29 HINT: make sure you have OpenGL install. On Ubuntu, you can run ‘apt-get install python-opengl’.
30 If you’re running on a server, you may need a virtual frame buffer; something like this should work:
31 ‘xvfb-run -s "-screen 0 1400x900x24" python <your_script.py>’
32 ‘’')
34 import math
35 import numpy as np

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

1 Like

dear Unagi.

Thank you for your contribution to the anaconda community.

OpenGL has been deprecated by Apple since 4.1, and support for Anaconda, which supports multiple platforms, is divided.

I think this is the cause, but when displaying an error code, I would like it if the user is asking for help or requesting an improvement.

Regarding this matter, we may not get a response from Anaconda officials because we do not know “Which opinion are you presenting?”

Best regards.
ktsh.tanaka.2020

Thanks for the response.
So I can´t run basic Pytorch in Anaconda if I use a Mac?
Why, then, people in the tutorials use Mac and this work for them?
From what I´m reading, let me know if I´m wrong, is that if I use a Mac then I can´t use it for AI projects if I use gym. Is this correct?
Thank you.