python - 安装特定版本后 pip 不升级
问题描述
$ lsb_release -a
LSB Version: :base-4.0-amd64:base-4.0-noarch:core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Distributor ID: CentOS
Description: CentOS release 6.7 (Final)
Release: 6.7
Codename: Final
$ sudo yum -y erase python-pip
$ ls -l /usr/bin/pip*
ls: cannot access /usr/bin/pip*: No such file or directory
$ sudo yum -y install python-pip
Running Transaction
Installing : python-pip-7.1.0-1.el6.noarch 1/1
Verifying : python-pip-7.1.0-1.el6.noarch 1/1
Installed:
python-pip.noarch 0:7.1.0-1.el6
Complete!
$ /usr/bin/pip --version
pip 7.1.0 from /usr/lib/python2.6/site-packages (python 2.6)
$ /usr/bin/pip2 --version
pip 7.1.0 from /usr/lib/python2.6/site-packages (python 2.6)
$ /usr/bin/pip2.6 --version
pip 7.1.0 from /usr/lib/python2.6/site-packages (python 2.6)
$ sudo pip2.6 install pip==9.0.3
You are using pip version 7.1.0, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting pip==9.0.3
Using cached https://files.pythonhosted.org/packages/ac/95/a05b56bb975efa78d3557efa36acaf9cf5d2fd0ee0062060493687432e03/pip-9.0.3-py2.py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 7.1.0
Uninstalling pip-7.1.0:
Successfully uninstalled pip-7.1.0
Successfully installed pip-9.0.0
$ /usr/bin/pip --version
pip 9.0.3 from /usr/lib/python2.6/site-packages (python 2.6)
$ /usr/bin/pip2 --version
pip 9.0.3 from /usr/lib/python2.6/site-packages (python 2.6)
$ /usr/bin/pip2.6 --version
pip 9.0.3 from /usr/lib/python2.6/site-packages (python 2.6)
为什么下面没有升级?
$ sudo pip2.6 install --upgrade pip
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
/usr/lib/python2.6/site-packages/pip/_vendor/urllib3/util/ssl_.py:339: SNIMissingWarning: An HTTPS request has been made, but the SNI (Subject Name Indication) extension to TLS is not available on this platform. This may cause the server to present an incorrect TLS certificate, which can cause validation failures. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
SNIMissingWarning
/usr/lib/python2.6/site-packages/pip/_vendor/urllib3/util/ssl_.py:137: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
InsecurePlatformWarning
Requirement already up-to-date: pip in /usr/lib/python2.6/site-packages
You are using pip version 9.0.3, however version 10.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
$ /usr/bin/pip --version
pip 9.0.3 from /usr/lib/python2.6/site-packages (python 2.6)
$ /usr/bin/pip2 --version
pip 9.0.3 from /usr/lib/python2.6/site-packages (python 2.6)
$ /usr/bin/pip2.6 --version
pip 9.0.3 from /usr/lib/python2.6/site-packages (python 2.6)
[vagrant@localhost ~]$
解决方案
pip 9 是在 Python 2.6 下工作的最后一个版本:
https://blog.python.org/2018/04/pip-10-has-been-released.html
不再支持 Python 2.6 - 如果您需要在 Python 2.6 上使用 pip,则应继续使用 pip 9,这是支持 Python 2.6 的最后一个版本。
推荐阅读
- c++ - 如何使用纯 WINAPI 在渐变背景上显示控件?
- ruby-on-rails - Rails 6表关联用户表与项目表关联
- python - 如何检查 Selenium (Python) 中是否存在元素?
- swift - 如何使用 UIGraphicsGetCurrentContext 检测对绘图的触摸?
- listview - 如何在用户的表单视图中显示列表视图更改历史记录?(奥多 13)
- swift - " NSLocalizedDescription = "神经网络中输出层 'Identity' 的大小与分类器中的类数不匹配。"
- python - 我该如何处理这个 PEP8 警告?
- linux - 为什么“xargs sudo perf top”没有按预期工作?
- azure-data-factory-2 - Azure 数据工厂,如何提供管道计划日期作为活动的价值
- swift - Sequence.compactMap 等效于具有可选值的元组