Joost Verbraeken
Joost Verbraeken

Reputation: 901

Py2exe does not include modules

When I use py2exe the program does not include the modules of my project. It gives this error:

Traceback (most recent call last):
    File "volex7.py", line 5, in <module>
    File "OpenGL\GL\__init__.pyc", line3, in <module>
    File "OpenGL\error.pyc", line 12, in <module>
    File "OpenGL\platform\__init__.pyc", line 35, in <module>
    File "OpenGL\platform\__init__.pyc", line 29 in _load
TypeError: 'NoneType' object is not callable

Apparently the OpenGL modules are not included, but why not and what can I do to solve this?

Upvotes: 3

Views: 314

Answers (1)

Civing
Civing

Reputation: 353

Try adding this to your main python file:

# Hack to make it work with py2exe
try:
    from OpenGL.platform import win32
except AttributeError:
    pass

That sorted things out for me. If you need another platform than win32, make sure to import that instead.

It seems like py2exe have a hard time understanding some __import__ statements made from class methods (in OpenGL/plugins.py). Therefore you can solve it by explicitly import the required OpenGL platform plugins in your main file.

Upvotes: 1

Related Questions