将pip升级到18.1之后,以下命令不再起作用:
wget https://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?
答案 0 :(得分:2)
根据最近的GitHub issue,get-pip.py
如何从命令行读取pip版本存在一个错误,但是票证描述了一种将版本约束放入文件中的解决方法:< / p>
python get-pip.py -c <(echo 'pip==18.0')
如果您不使用bash
,则需要在单独的命令中创建文件并将其传递到get-pip.py
:
echo 'pip==18.0' > /tmp/pip-version.txt
python get-pip.py -c /tmp/pip-version.txt
答案 1 :(得分:1)
下面是另一个尝试过的解决方案:
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 --version
$ pip 18.1 from /home/moez/.local/lib/python2.7/site-packages/pip (python 2.7)
如果在检查pip版本时得到以下输出:
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main
然后,打开文件/ usr / bin / pip并将代码替换为:
from pip import __main__
if __name__ == '__main__':
sys.exit(__main__._main())