JoesLost
JoesLost

Reputation: 41

Import Errror for python pg module

I am having trouble using the pg module in my code. I've installed it using pip. But when I go to run it I get the following error:

Traceback (most recent call last):
  File "Contract_gen.py", line 2, in <module>
    import pg
  File "C:\Python27\lib\site-packages\pg\__init__.py", line 1, in <module>
    from .core import (
  File "C:\Python27\lib\site-packages\pg\core.py", line 6, in <module> 
    from . import glfw
  File "C:\Python27\lib\site-packages\pg\glfw.py", line 140, in <module>
    raise ImportError("Failed to load GLFW3 shared library.")
ImportError: Failed to load GLFW3 shared library.

Upvotes: 2

Views: 5207

Answers (3)

RasmusN
RasmusN

Reputation: 168

How to solve for windows:

  1. Download Windows pre-compiled binaries from https://www.glfw.org/download.html
  2. copy (and replace) the file lib-mingw-w64\glfw3.dll to ...\Python27\Lib\site-packages\glfw\glfw3.dll
  3. Done

For me, glfw was working fine until one morning when it suddenly wasn't. This solution worked for me. I don't know if this is the correct way to solve it but it worked for me.

Upvotes: 0

Rapha&#235;l Poli
Rapha&#235;l Poli

Reputation: 74

Your version of OpenGL might be too old compared to the pg requirement which is 3.1.0 as specified in https://github.com/fogleman/pg/blob/master/requirements.txt

You can re install python-openGL with pip:

$ pip install PyOpenGL PyOpenGL_accelerate

This removes this problem but creates other errors for me.

note, besides, that this problem seems to be mentioned in https://github.com/fogleman/pg/issues

Upvotes: 0

Armen Avetisyan
Armen Avetisyan

Reputation: 1258

It seems like to require the GLFW3 library. Download & install it and the error should be gone. If you use macOS you can get it via brew.

Upvotes: 3

Related Questions