py2app and OpenGL, "No module named util" in ctypes

Carl Banks pavlovevidence at gmail.com
Thu May 28 18:28:34 EDT 2009


On May 28, 11:06 am, trhaynes <trhay... at gmail.com> wrote:
> I'm trying to use py2app to package an OpenGL app, so first I tried to
> build the example here
>
> http://svn.pythonmac.org/py2app/py2app/trunk/examples/PyOpenGL/
>
> and I get the error:
>
> >  File "/opt/local/lib/python2.5/site-packages/PyOpenGL-3.0.0c1-py2.5.egg/OpenGL/platform/darwin.py", line 24, in <module>
> >    import ctypes, ctypes.util
> >ImportError: No module named util
> >2009-05-28 13:55:06.819 lesson5[19965:10b] lesson5 Error
> >2009-05-28 13:55:06.821 lesson5[19965:10b] lesson5 Error
> >An unexpected error has occurred during execution of the main script
>
> >ImportError: No module named util
>
> But when I open up my python interactive interpreter and "import
> ctypes.util", it works fine (using lesson5.app/Contents/MacOS/python,
> too).
>
> Thanks for the help.

What has happened is that py2app didn't bundle ctypes.util with the
app, because py2app failed to detect that it was imported for some
reason.

A typical workaround is to imported in maually in your main script to
make it explicit to py2app that it should be packaged.

A word of caution: PyOpenGL uses entry hooks and that can cause a lot
of trouble for application builder utilities like py2exe and py2app.
In fact, I decided to stop using PyOpenGL in my projects in large part
because of that issue (I use my own OpenGL wrapper now).  It's
possible py2app has learned to deal with entry hooks by now, but these
days I refuse to use packages that require entry hooks so I wouldn't
know.


Carl Banks



More information about the Python-list mailing list