Python 如何使用PIP18.1安装特定的pip版本?
pip升级到18.1后,以下命令不再工作:Python 如何使用PIP18.1安装特定的pip版本?,python,pip,Python,Pip,pip升级到18.1后,以下命令不再工作: wgethttps://bootstrap.pypa.io/get-pip.py -O get-pip.py&&python/tmp/get-pip.py pip==9.0.1 错误消息是: Created temporary directory: /tmp/pip-ephem-wheel-cache-DgcFrM Created temporary directory: /tmp/pip-req-tracker-oBsk3Z Created requ
wgethttps://bootstrap.pypa.io/get-pip.py -O get-pip.py&&python/tmp/get-pip.py pip==9.0.1
错误消息是:
Created temporary directory: /tmp/pip-ephem-wheel-cache-DgcFrM
Created temporary directory: /tmp/pip-req-tracker-oBsk3Z
Created requirements tracker '/tmp/pip-req-tracker-oBsk3Z'
Created temporary directory: /tmp/pip-install-FAvXbK
Cleaning up...
Removed build tracker '/tmp/pip-req-tracker-oBsk3Z'
Double requirement given: pip (already in pip==9.0.1, name='pip')
Exception information:
Traceback (most recent call last):
File "/tmp/tmpq8by8x/pip.zip/pip/_internal/cli/base_command.py", line 143, in main
status = self.run(options, args)
File "/tmp/tmpq8by8x/pip.zip/pip/_internal/commands/install.py", line 293, in run
self.name, wheel_cache
File "/tmp/tmpq8by8x/pip.zip/pip/_internal/cli/base_command.py", line 220, in populate_requirement_set
requirement_set.add_requirement(req_to_add)
File "/tmp/tmpq8by8x/pip.zip/pip/_internal/req/req_set.py", line 108, in add_requirement
% (install_req, existing_req, name)
InstallationError: Double requirement given: pip (already in pip==9.0.1, name='pip')
如何使用新版本的get-pip.py安装pip?根据最近的研究,get-pip.py如何从命令行读取pip版本中存在一个错误,但问题描述了一种解决方法,包括将版本约束放入文件中:
python get-pip.py -c <(echo 'pip==18.0')
根据最近的这篇文章,在如何从命令行读取pip版本方面存在一个bug,但该问题描述了一种解决方法,涉及将版本约束放入文件中:
python get-pip.py -c <(echo 'pip==18.0')
下面是另一个尝试过的解决方案:
PIPVERSION=18.1
然后:
curl -o /tmp/get-pip.py -sSL "https://bootstrap.pypa.io/get-pip.py"
并触发安装:
python /tmp/get-pip.py pip==${PIPVERSION}
验证pip版本:(根据我的终端输出)
如果在检查pip版本时获得以下输出:
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main
下面是另一个尝试过的解决方案:
PIPVERSION=18.1
然后:
curl -o /tmp/get-pip.py -sSL "https://bootstrap.pypa.io/get-pip.py"
并触发安装:
python /tmp/get-pip.py pip==${PIPVERSION}
验证pip版本:(根据我的终端输出)
如果在检查pip版本时获得以下输出:
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main