[PyQt] PyQt4 import module fails second time when running python from Qt-C++ based shell

Jack Cosgrove jackcosgrove at gmail.com
Fri May 6 06:05:19 BST 2011


I've attached a small Qt project for a Python shell. It also uses
QScintilla. It's amazing that I made this in about 5 minutes, thanks

The problem I'm encountering is that I can only correctly import a PyQt4
module once using this shell. If I try to import again then I cannot use
classes within the module. The code

from PyQt4 import QtCore

succeeds the first time it is run. The second time it complains that
"AttributeError: 'module' object has no attribute 'QObject'". This does
not happen with other modules like sys. The Python execution code uses
all temporary variables.

At first I thought this was because of a flaw in my C++ code, but the
success of loading a non-Qt-based modules piqued my curiosity. Has
anyone ever seen something like this?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sample.tar.gz
Type: application/x-compressed-tar
Size: 1941 bytes
Desc: not available
URL: <http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20110506/e85ec735/attachment-0001.bin>

More information about the PyQt mailing list