On 10/8/2010 3:47 PM, Raoul Snyman wrote:
On 8 October 2010 18:40, Nathan Weston<[email protected]>  wrote:
My program looks like this:
# qthello.py
import sys
import sip
import PyQt4.QtCore
import PyQt4.QtGui

app = PyQt4.QtGui.QApplication(sys.argv)
window = PyQt4.QtGui.QMainWindow()
window.setCentralWidget(PyQt4.QtGui.QLabel("Hello"))
window.show()
sys.exit(app.exec_())
# end of qthello.py

Your application is incorrect. You have to import PyQt4 like so:

from PyQt4 import QtCore, QtGui

Thanks, that fixes the problem. But it seems like a stretch to call the program "incorrect" when it works just fine. Why does PyInstaller understand one form of import but not the other?

Also, there is no need to import sip.


True. In my real program I'm importing sip to do this:

import sip
sip.setapi('QString', 2)
sip.setapi('QVariant', 2)
from PyQt4.QtCore import *
from PyQt4.QtGui import *

Which leads me to another problem. When I package the larger program with PyInstaller and run the EXE, I get this error:

ValueError: API 'QString' has already been set to version 1

It seems as though PyQt is somehow getting loaded before my sip.setapi calls, even though I haven't explicitly imported it yet. Again, it works correctly when I run the .py file directly. Is there a workaround for this?

- Nathan

--
You received this message because you are subscribed to the Google Groups 
"PyInstaller" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pyinstaller?hl=en.

Reply via email to