question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImportError: Library "GL" not found

See original GitHub issue

Hi, I get the following error when trying to run DQN baseline. I have opengl already installed. and glxgears, glxinfo already work fine. I am using python 3.5. can someone please let me know how to fix this?

“python -m baselines.deepq.experiments.enjoy_cartpole” gym.utils.reraise.ReraisedException: Error occured while running from pyglet.gl import * The original exception was:

ImportError: Library “GL” not found.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
ziyanglicommented, Mar 19, 2019

I have the same problem. I tried this and no error occurs.

Python 3.6.3 (default, Oct  6 2017, 00:00:00) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyglet.gl import *
>>> gl_lib = pyglet.lib.load_library('GL')
>>> 
>>> 

But if I run

python -m baselines.run --alg=deepq --env=CartPole-v0 --load_path=./cartpole_model.pkl --num_timesteps=0 --play

then there is a problem

Instructions for updating:
Use tf.cast instead.
Loaded model from ./cartpole_model.pkl
Running trained model
Traceback (most recent call last):
  File "/home/lzy/git/gym/gym/envs/classic_control/rendering.py", line 27, in <module>
    from pyglet.gl import *
  File "/home/lzy/py3_ws/lib/python3.6/site-packages/pyglet/gl/__init__.py", line 100, in <module>
    from pyglet.gl.lib import GLException
  File "/home/lzy/py3_ws/lib/python3.6/site-packages/pyglet/gl/lib.py", line 143, in <module>
    from pyglet.gl.lib_glx import link_GL, link_GLU, link_GLX
  File "/home/lzy/py3_ws/lib/python3.6/site-packages/pyglet/gl/lib_glx.py", line 50, in <module>
    gl_lib = pyglet.lib.load_library('GL')
  File "/home/lzy/py3_ws/lib/python3.6/site-packages/pyglet/lib.py", line 158, in load_library
    raise ImportError('Library "%s" not found.' % names[0])
ImportError: Library "GL" not found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.6/runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "/usr/lib/python3.6/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/home/lzy/git/baselines/baselines/run.py", line 252, in <module>
    main(sys.argv)
  File "/home/lzy/git/baselines/baselines/run.py", line 239, in main
    env.render()
  File "/home/lzy/git/baselines/baselines/common/vec_env/dummy_vec_env.py", line 79, in render
    return self.envs[0].render(mode=mode)
  File "/home/lzy/git/gym/gym/core.py", line 244, in render
    return self.env.render(mode, **kwargs)
  File "/home/lzy/git/gym/gym/core.py", line 244, in render
    return self.env.render(mode, **kwargs)
  File "/home/lzy/git/gym/gym/envs/classic_control/cartpole.py", line 150, in render
    from gym.envs.classic_control import rendering
  File "/home/lzy/git/gym/gym/envs/classic_control/rendering.py", line 34, in <module>
    ''')
ImportError: 
    Error occured 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>'
1reaction
ariel415elcommented, Jun 3, 2020

Thanks @Deastan ! adding from pyglet.gl import * in the main scriipt did the trick for me

Read more comments on GitHub >

github_iconTop Results From Across the Web

ImportError: Error occured while running `from pyglet.gl ...
I tried installing GL when I got the import error but it still gives me the same error. ... names[0]) ImportError: Library "GL"...
Read more >
ImportError: Library "GL" not found.
I received the following message trying to run Pyglet. ImportError: Library "GL" not found.
Read more >
ImportError: Library "GL" not found.
I'm trying to install pyglet on Python 2.5.1 on Solaris 10. When trying to run a test program, I get the following:
Read more >
How to Fix Error: No Module Named 'OpenGL'
Quick Fix: Python raises the ImportError: No module named 'opengl' when it cannot find the library opengl . The most frequent source of...
Read more >
OpenGL Troubles
missing DLL (name is unknown) · Step 1: locate the related PYD file (a kind of Python DLL) - it resides just next...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found