1
votes

I have an apparently older version of PyQt5 installed on my Xubuntu (Voyager). When I print the PYQT_VERSION_STR, it displays: '5.2.1'. I downloaded the latest PyQt5 release form here: http://sourceforge.net/projects/pyqt/files/PyQt5/PyQt-5.4/ I configured it, make and make installed it, everything went according to plan. However, if I print the PYQT_VERSION_STR again, it still outputs '5.2.1'.

How do I tell my python3.4 to use the updated version?

(Shouldn't the reinstall of the new version overwrite the other one? I don't understand why it is still showing 5.2.1 as version string.)

EDIT #1:

sys.path: ['', '/home/user/.pythonbrew/lib', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload', '/usr/local/lib/python3.4/dist-packages', '/usr/lib/python3/dist-packages']

PyQt5.__file__ '/usr/lib/python3/dist-packages/PyQt5/init.py'

So it seems my python is using the version from the repositories, except if that's where it got installed when make installing.

EDIT #2:

It seems that the PYQT_VERSION_STR returns the version of Qt (!) which the PyQt5 configuration before making and make installing found. So the actual issue seems to be with my Qt5 version, which is 5.2.1 according to the output of python configure of PyQt5:

Querying qmake about your Qt installation...
Determining the details of your Qt installation...
This is the GPL version of PyQt 5.4 (licensed under the GNU General Public License) for Python 3.4.0 on linux.

Type 'L' to view the license.
Type 'yes' to accept the terms of the license.
Type 'no' to decline the terms of the license.

Do you accept the terms of the license? yes
Found the license file pyqt-gpl.sip.
Checking [...]


DBus v1 does not seem to be installed.
Qt v5.2.1 (Open Source) is being used.
The qmake executable is /usr/bin/qmake.
Qt is built as a shared library.
SIP 4.16.5 is being used.
The sip executable is /usr/bin/sip.
These PyQt5 modules will be built: QtCore, QtGui, QtNetwork, QtOpenGL,
QtPrintSupport, QtQml, QtQuick, QtSql, QtTest, QtWidgets, QtXml, QtDBus, _QOpenGLFunctions_2_0.

The PyQt5 Python package will be installed in /usr/lib/python3.4/site-packages.
PyQt5 is being built with generated docstrings.
PyQt5 is being built with 'protected' redefined as 'public'.
The Designer plugin will be installed in
/usr/lib/x86_64-linux-gnu/qt5/plugins/designer.
The qmlscene plugin will be installed in
/usr/lib/x86_64-linux-gnu/qt5/plugins/PyQt5.
The PyQt5 .sip files will be installed in /usr/share/sip/PyQt5.
pyuic5, pyrcc5 and pylupdate5 will be installed in /usr/bin.
The interpreter used by pyuic5 is /usr/bin/python3.
Generating the C++ source for the QtCore module...
Embedding sip flags...
Generating [...]

Re-writing
/home/xiaolong/Downloads/PyQt-gpl-5.4/examples/quick/tutorials/extending/chapter6-plugins/Charts/qmldir...
Generating the top-level .pro file...
Making the pyuic5 wrapper executable...
Generating the Makefiles...

So the PyQt5 is going into the correct directory, but the actual version of Qt5 is older than 5.4. Now the question seems turns into "How do I update my Qt5 version?" unless I misunderstood something here.

EDIT #3:

Output of sys.executable:

Python 3.4.0 (default, Apr 11 2014, 13:05:11) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.executable
'/usr/bin/python3'
>>> 

EDIT #4:

Contents of my .bash_aliases file: alias python=python3 alias pip=pip3

1
Have you tried an apt-get update followed by apt-get upgrade?Alex Martelli
Yes, I do that almost every day :) But The version in the repositories is older than the up to date version from source forge, which I compiled and installed now.Zelphir Kaltstahl
the problem might be that Ubuntu places its (older) version ahead on the PYTHONPATH from where your locally installed (newer) version gets placed. Check the __file__ from which the older PyQt version gets loaded vs the directory where the newer one got installed, and in what order the dirs are in sys.path.Alex Martelli
The sys.path doesn't seem to have any other directory than the site packages: ['', '/home/user/.pythonbrew/lib', '/usr/lib/python3.4', '/usr/lib/python3.4/plat-x86_64-linux-gnu', '/usr/lib/python3.4/lib-dynload', '/usr/local/lib/python3.4/dist-packages', '/usr/lib/python3/dist-packages'] How do I check the __file__ from which it is loaded?Zelphir Kaltstahl
you import PyQt5 from an interactive Python interpreter, and show PyQt5.__file__.Alex Martelli

1 Answers

1
votes

EDIT:

I have been assuming that the suggestions made in the initial comments to your question somehow didn't work for you, and so I guessed that there must be a second python installation on your system. But after reading through everything again, it seems that in fact you didn't follow through on all the hints that were given.

It looks like this is simply a case of dist-packages vs site-packages. On Debian-based systems, the python packages supplied by the distro are installed in dist-packages, whereas user-installed packages would normally be installed in site-packages. This is done to minimise the chances of breaking other system applications which rely on specific versions of python packages.

The output from the PyQt5 configuration script shows that you installed it to site-packages:

The PyQt5 Python package will be installed in /usr/lib/python3.4/site-packages.

But that directory does not appear in your sys.path, and so python cannot import packages from that location.

There are several ways to fix this, but some are "safer" than others. For instance, you could manipulate the python path in various ways, but that has the significant downside of affecting all python applications (including ones using python2), so it's probably best avoided.

Since there are probably very few system applications that rely on PyQt-5.2.1, it should be okay to simply override it. To do that, re-compile and install PyQt-5.4 by configuring it like this:

    python3 configure.py --destdir=/usr/local/lib/python3.4/dist-packages

Alternatively, you could uninstall your system PyQt5 package (using apt-get, or whatever), and replace it altogether by configuring like this:

    python3 configure.py --destdir=/usr/lib/python3/dist-packages

And as a final step, you should probably tidy things up by removing the redundant PyQt5 directory from /usr/lib/python3.4/site-packages.