[PyQt] Moving PyQt programs to Python 3

Baz Walter bazwal at ftml.net
Fri Jul 15 15:16:13 BST 2011


On 15/07/11 07:48, Algis Kabaila wrote:
> Currently reputable distros such as ubuntu do not package binaries of PyQt
> with Python3.  There are other "unsupported binaries" in some ppa's (Personal
> Packaging Archives)..  The ones that I looked at do not bother to tell me what
> version of Python they are bound to - I assume it is 2.x.
>
> Also, when I do ask "how do I find out what Python version this PyQt binary is
> bound to", the real question is "how does someone satisfy a helper on this
> list that the PyQt binary she/he is using is bound to Python 3.x".  How else
> hers/his questions can be answered without suspicion of mismatch of binaries
> for PyQt and Python version being seen as the probable reason why "her/his"
> code works on helpers PC and not his/hers?

if a user can successfully import a pyqt module for a given python 
major/minor version, then there will be no "mismatch".

so a simple test would be to run a python interactive session and try 
something like: 'from PyQt4 import QtCore'. if there is a "mismatch", an 
ImportError will occur. (note that 'import PyQt4' would not be a good 
test, because that will just import PyQt4/__init__.py, which does nothing).

here's what happens on my system when i try to import the *wrong* pyqt:

Python 3.2 (r32:88445, Apr 15 2011, 11:20:08)
[GCC 4.5.2 20110127 (prerelease)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> os.chdir('/usr/lib/python2.7/site-packages')
 >>> from PyQt4 import QtCore
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
ImportError: PyQt4/QtCore.so: undefined symbol: PyInt_Type
 >>>

Python 2.7.2 (default, Jun 29 2011, 11:17:09)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> os.chdir('/usr/lib/python3.2/site-packages')
 >>> from PyQt4 import QtCore
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
ImportError: PyQt4/QtCore.so: undefined symbol: 
PyUnicodeUCS4_CompareWithASCIIString
 >>>

Python 2.6.5 (r265:79063, Jul 15 2011, 14:43:13)
[GCC 4.6.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> os.chdir('/usr/lib/python2.7/site-packages')
 >>> from PyQt4 import QtCore
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
ImportError: PyQt4/QtCore.so: undefined symbol: PyCapsule_Type
 >>>


More information about the PyQt mailing list