hello everybody, im coding a game with opengl,pyggel,python,pygame etc
and it runs smoothly without any problems =)
www.youtube.com/watch?v=JlDuje39S_8 - My python 3d game projekt <--- sorry if outside links isnt allowed =(
But the thing is that when im compiling it with py2exe using this as setup.py

from distutils.core import setup
import py2exe

setup(windows=['game.pyw'],
      options={
          "py2exe": {
              "includes": ["ctypes", "logging"],
              }
          }
      )

and after i compiled it and finish with everything and run it i get this error

Traceback (most recent call last):
  File "game.pyw", line 2, in <module>
  File "pyggel\__init__.pyc", line 7, in <module>
  File "pyggel\include.pyc", line 12, in <module>
  File "OpenGL\GL\__init__.pyc", line 2, in <module>
  File "OpenGL\raw\GL\__init__.pyc", line 6, in <module>
  File "OpenGL\raw\GL\constants.pyc", line 7, in <module>
  File "OpenGL\platform\__init__.pyc", line 36, in <module>
  File "OpenGL\platform\__init__.pyc", line 27, in _load
  File "OpenGL\plugins.pyc", line 14, in load
  File "OpenGL\plugins.pyc", line 28, in importByName
ImportError: No module named win32

I tried downloading and installing pywwin32 but same prob,what should i do ?

oki i solved the problem and i really dont whant anybody else to have this prob without finding a solutin so here is how i solved it


In your setup.py, exclude OpenGL although you have PyOpenGL installed. I needed to explicitly include ctypes and logging to make it work, but maybe that depends on what things you use. My setup.py:

from distutils.core import setup
import py2exe

setup(windows=['opdracht.py'],
      options={
          "py2exe": {
              "includes": ["ctypes", "logging"],
              "excludes": ["OpenGL"],
              }
          }
      )

At the top of your main Python file, add the current directory ('.') to your sys.path:

import sys
sys.path += ['.']

Run setup.py py2exe.


Copy the OpenGL folder from PYTHONDIR\Lib\site-packages to your new dist\ directory. I think it's in C:\Python26\Lib\site-packages by default. You can leave out any *.pyc and *.pyo files.
this worked for me =)

Hi,
I'm also experiencing problems with trying to make an .exe out of my pyOpenGL project. I spent several hours googling and the post of Friktion definitely helped. To be clear, I also exclude OpenGL and include ctypes for py2exe and add the directory of the exe to the path.

Since I am also using pygame, I use a script for this, found at http://www.pygame.org/wiki/Pygame2exe, but this is, I think, not a part of the problem.

I am now able to get to a point were I have the following errormessage when I run the exe:

Traceback (most recent call last):
  File "game003.py", line 12, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "OpenGL\GL\__init__.pyo", line 2, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "OpenGL\raw\GL\__init__.pyo", line 6, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "OpenGL\raw\GL\constants.pyo", line 7, in <module>
  File "zipextimporter.pyo", line 82, in load_module
  File "OpenGL\arrays\__init__.pyo", line 22, in <module>
  File "OpenGL\arrays\formathandler.pyo", line 37, in loadAll
  File "OpenGL\arrays\formathandler.pyo", line 44, in loadPlugin
  File "OpenGL\plugins.pyo", line 14, in load
  File "OpenGL\plugins.pyo", line 28, in importByName
  File "zipextimporter.pyo", line 82, in load_module
  File "OpenGL\arrays\strings.pyo", line 8, in <module>
  File "ctypes\__init__.pyo", line 366, in __getattr__
  File "ctypes\__init__.pyo", line 371, in __getitem__
AttributeError: function 'PyString_AsString' not found

This error apparently comes from line 8 in "OpenGL\arrays\strings.pyo" which is 'psas = ctypes.pythonapi.PyString_AsString'

So what is this PyString_AsString function? As far as I could figure out this is a function of the python ctypes library, intended to pass a string from C to python (or the other way around). When I import ctypes in my python interperter (I used ipython) and look what functions are available, this function doesn't seem to exsist in pythonapi. When I use the exact line from "OpenGL\arrays\strings.pyo" it doesn't give an error but actually creates this function. It seems that ctypes\__init__.py is able to create this function on the fly, because when I check again after running this line, the function does exist. This corresponds to what you would expect from the __getattr__ function. But, why doesn't my executable want to do this?

A possible solution would be to install pyOpenGL version 2.x, since this doens't use ctypes. Like this guy did http://thorbrian.com/pyopengl/builds.php. This would mean, however, that I need to install python 2.5 too (I'm now using python 2.6 and pyopengl 3.0.1b2). And I don't want to use that yet. So does anybody have any idea how solve this?

py2exe cannot understand any import statements that happen in conditional blocks. First off, the only thing I've seen that works with OpenGL is to put the following in for the includes and excludes:

setup(options = {"py2exe": {"compressed": 1,
"optimize": 2,
"includes": ["ctypes","Tkinter","Numeric"],
"excludes": ["OpenGL"]

and then copy your entire OpenGL file to the distribution folder. For other things, if it wants the module win32, at the beginning of your main routine put

import win32

now py2exe will know that it needs to include it.


hello everybody, im coding a game with opengl,pyggel,python,pygame etc
and it runs smoothly without any problems =)
www.youtube.com/watch?v=JlDuje39S_8 - My python 3d game projekt <--- sorry if outside links isnt allowed =(
But the thing is that when im compiling it with py2exe using this as setup.py

from distutils.core import setup
import py2exe

setup(windows=['game.pyw'],
      options={
          "py2exe": {
              "includes": ["ctypes", "logging"],
              }
          }
      )

and after i compiled it and finish with everything and run it i get this error

Traceback (most recent call last):
  File "game.pyw", line 2, in <module>
  File "pyggel\__init__.pyc", line 7, in <module>
  File "pyggel\include.pyc", line 12, in <module>
  File "OpenGL\GL\__init__.pyc", line 2, in <module>
  File "OpenGL\raw\GL\__init__.pyc", line 6, in <module>
  File "OpenGL\raw\GL\constants.pyc", line 7, in <module>
  File "OpenGL\platform\__init__.pyc", line 36, in <module>
  File "OpenGL\platform\__init__.pyc", line 27, in _load
  File "OpenGL\plugins.pyc", line 14, in load
  File "OpenGL\plugins.pyc", line 28, in importByName
ImportError: No module named win32

I tried downloading and installing pywwin32 but same prob,what should i do ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.