No, this is supposed to work. Are you using the standard GPL installer
of PyQt from Riverbank's site or have you built PyQt yourself?
--
Giovanni Bajo :: ra...@develer.com
Develer S.r.l. :: http://www.develer.com
I'm using the Riverbank installer: PyQt4 GPL v4.7.4 for Python 2.6. I'm
running Windows 7 64-bit, but Python and PyQt are 32-bit.
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
I built it like so:
python Makespec.py qthello.py
python Build.py qthello\qthello.spec
Let me know if there's any other information I can provide.
Your application is incorrect. You have to import PyQt4 like so:
from PyQt4 import QtCore, QtGui
Also, there is no need to import sip.
--
Raoul Snyman
B.Tech Information Technology (Software Engineering)
E-Mail: raoul....@gmail.com
Web: http://www.saturnlaboratories.co.za/
Blog: http://blog.saturnlaboratories.co.za/
Mobile: 082 550 3754
Registered Linux User #333298 (http://counter.li.org)
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
Yes, it is.
put the following lines somewhere at the top in
file ./trunk/support/rthooks/pyi_rth_qt4plugins.py
No reason, actually, sounds like a bug (though it's hard to believe
since it's a pretty common form of imports). I'll have a look.