Reputation: 1301
Using Python 3.6.9 and pip 9.0.1 on Ubuntu Studio 18.04, I was trying to downgrade the PyQt5 module from version 5.10.1 to 5.9.2.
The installation seems to complete without a problem, but pip3 confirms that 5.10.1 was installed successfully:
pip3 install --no-cache-dir 'PyQt5==5.9.2'
Output:
Collecting PyQt5==5.9.2
Downloading https://files.pythonhosted.org/packages/3a/c6/26270f5550f00920045c2f0b222a7d03d7a64382825c68bf0bb1a51d854c/PyQt5-5.9.2-5.9.3-cp35.cp36.cp37-abi3-manylinux1_x86_64.whl (105.3MB)
100% |████████████████████████████████| 105.3MB 11.0MB/s
Collecting sip<4.20,>=4.19.4 (from PyQt5==5.9.2)
Downloading https://files.pythonhosted.org/packages/8a/ea/d317ce5696dda4df7c156cd60447cda22833b38106c98250eae1451f03ec/sip-4.19.8-cp36-cp36m-manylinux1_x86_64.whl (66kB)
100% |████████████████████████████████| 71kB 4.2MB/s
Installing collected packages: sip, PyQt5
Successfully installed PyQt5-5.10.1 sip-4.19.8
Checking the current version:
pip3 show PyQt5
Output:
Name: PyQt5
Version: 5.10.1
Summary: Python bindings for the Qt cross platform UI and application toolkit
Home-page: https://www.riverbankcomputing.com/software/pyqt/
Author: Riverbank Computing Limited
Author-email: [email protected]
License: GPL v3
Location: /home/stragu/.local/lib/python3.6/site-packages
Requires: sip
I also tried uninstalling and installing it again, but I end up with version 5.10 (i.e. not 5.10.1) installed. It's like it forces version 5.10 as a minimum.
However, when I do the following in a Python3 kernel:
from PyQt5.Qt import PYQT_VERSION_STR
print("PyQt version:", PYQT_VERSION_STR)
I find out it is apparently using version 5.9.2!
Any idea what might be going on here?
Upvotes: 0
Views: 1231
Reputation: 1301
It seems it is a problem with the default version of pip3 on this installation, version 9.0.1, which always reports (at the end of the install, or when listing the module versions with pip3 list
) the module's highest version ever installed.
I upgraded pip3 with:
python3 -m pip install --upgrade pip
And it now works as expected, reporting the right module version number the user asked for (which matches whatever is retrieved when looking for the relevant module's version number from a Python3 kernel).
Upvotes: 2
Reputation: 36096
You are using your system's Python. This module is also installed system-wide with Apt. The strangeness in Pip's behaviour is due to a Debian patch.
I (blindly) guessed the 1st one by checking PyQt5 packages in Bionic which shows version number 5.10.1
that you see.
Examining the patches in the source archive for pip 9.0.1-2.3~ubuntu1.18.04.1
(available from https://launchpad.net/ubuntu/+source/python-pip/9.0.1-2.3~ubuntu1.18.04.1) shows the following relevant change in set_user_default.patch
:
When running as a normal user in a non-virtual environment, default to --user and --ignore-installed.
(I guess it's intended to fix UX for pip install
here in comparison to earlier behavior which denied system-wide installation with a logical but obscure error.)
However, the patch only applies this to the install
command.
So you install PyQt5-5.9.2
to user site -- while pip3 show
shows you the package at the system site and you need to run pip3 list --user
to see the latter.
I don't know why exactly pip3 install
showed a wrong version at the end but guess that line is generated by the same code that powers pip3 show
.
Upvotes: 0