2

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.
Vzzarr
  • 4,600
  • 2
  • 43
  • 80
JoesLost
  • 41
  • 1
  • 5

3 Answers3

3

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.

Armen Avetisyan
  • 1,140
  • 10
  • 29
0

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

0

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.

RasmusN
  • 147
  • 1
  • 12