简体   繁体   English

pip3 没有安装目标模块版本

[英]pip3 does not install the target module version

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.在 Ubuntu Studio 18.04 上使用 Python 3.6.9 和 pip 9.0.1,我试图将 PyQt5 模块从版本 5.10.1 降级到 5.9.2。

The installation seems to complete without a problem, but pip3 confirms that 5.10.1 was installed successfully:安装似乎没有问题就完成了,但是pip3确认5.10.1安装成功:

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: info@riverbankcomputing.com
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 (ie not 5.10.1) installed.我也尝试卸载并再次安装它,但我最终安装了 5.10 版(即不是5.10.1)。 It's like it forces version 5.10 as a minimum.就像它至少强制使用 5.10 版一样。

However, when I do the following in a Python3 kernel:但是,当我在 Python3 内核中执行以下操作时:

from PyQt5.Qt import PYQT_VERSION_STR
print("PyQt version:", PYQT_VERSION_STR)

I find out it is apparently using version 5.9.2!我发现它显然使用的是 5.9.2 版!

Any idea what might be going on here?知道这里会发生什么吗?

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.此安装中的默认 pip3 版本 9.0.1 似乎存在问题,该版本始终报告(在安装结束时,或在使用pip3 list模块版本时)该模块有史以来安装的最高版本。

I upgraded pip3 with:我用以下方法升级了 pip3:

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).现在它按预期工作,报告用户要求的正确模块版本号(与从 Python3 内核查找相关模块的版本号时检索到的任何内容相匹配)。

You are using your system's Python.您正在使用系统的 Python。 This module is also installed system-wide with Apt.该模块也与 Apt 一起安装在系统范围内。 The strangeness in Pip's behaviour is due to a Debian patch. Pip 行为的奇怪之处在于 Debian 补丁。


I (blindly) guessed the 1st one by checking PyQt5 packages in Bionic which shows version number 5.10.1 that you see.我(盲目地)通过检查 Bionic中显示版本号5.10.1 PyQt5 包来猜到第一个。

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 :检查pip 9.0.1-2.3~ubuntu1.18.04.1源存档中的补丁(可从https://launchpad.net/ubuntu/+source/python-pip/9.0.1-2.3~ubuntu1.18.04 获得。 1 ) 显示了set_user_default.patch中的以下相关更改:

When running as a normal user in a non-virtual environment, default to --user and --ignore-installed.在非虚拟环境中以普通用户身份运行时,默认为--user 和--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 .) (我想这是为了修复pip install UX 与早期的行为相比, 后者拒绝系统范围的安装并出现逻辑但模糊的错误。)

However, the patch only applies this to the install command.但是,补丁仅将此应用于install命令。

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.因此,您将PyQt5-5.9.2安装到用户站点——而pip3 show向您显示系统站点上的包,您需要运行pip3 list --user以查看后者。

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 .我不知道为什么pip3 install在最后显示了错误的版本,但猜测该行是由支持pip3 show的相同代码生成的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM