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

T

trhaynes

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.

-tom
 
N

norseman

Ned said:
I'm trying to use py2app to package an OpenGL app [...]

You might try asking on the pythonmac-sig list: more py2app users there
most likely.

http://mail.python.org/mailman/listinfo/pythonmac-sig
[or]
http://dir.gmane.org/gmane.comp.python.apple
=========================
trhaynes;

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

That's funny:

import ctypes
help(ctypes)
--- start screen dump ---
Help on package ctypes:

NAME
ctypes - create and manipulate C data types in Python

FILE
/usr/local/lib/python2.5/ctypes/__init__.py

MODULE DOCS
/mnt/mass/py/man/py-chm/module-ctypes.html

PACKAGE CONTENTS
_endian
macholib (package)
test (package)
util <<<<<-------------
wintypes

CLASSES
__builtin__.object
CDLL
PyDLL
LibraryLoader
--- end screen dump ---

I assume py2app can't find/load it??? I wasn't in at the start of this
thread.

If you do need it,

import ctypes
from ctypes import util

I know the *import ctypes* line is supposed to be *not needed*, but I
find Python works more as expected with it.


I also assume you have seen .../pythonXX/distutils and dist.pdf? Just
in case you have not - take a look. Supposed to be how to package one's
stuff for distribution.

At least with python 2.5.2
on Linux Slackware 10.2
Today is: 20090528



Steve
 
C

Carl Banks

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
 
T

trhaynes

I'm trying to use py2app to package an OpenGL app, so first I tried to
build the example here

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

Thanks all. I had to add ctypes.util to the list of includes for it
to work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top