简体   繁体   English

pip 在 python2 上安装失败

[英]pip install failing on python2

Following the instructions on this page to install pip on python2 https://linuxhint.com/installing_pip_linux_mint/按照此页面上的说明在 python2 https://linuxhint.com/installing_pip_linux_mint/ 上安装 pip

It's failing at the last step, $ sudo python2 get-pip.py它在最后一步失败了, $ sudo python2 get-pip.py

with this error,有了这个错误,

Traceback (most recent call last):
  File "get-pip.py", line 24226, in <module>
    main()
  File "get-pip.py", line 199, in main
    bootstrap(tmpdir=tmpdir)
  File "get-pip.py", line 82, in bootstrap
    from pip._internal.cli.main import main as pip_entry_point
  File "/tmp/tmp2aZyDl/pip.zip/pip/_internal/cli/main.py", line 60
    sys.stderr.write(f"ERROR: {exc}")
                                   ^
SyntaxError: invalid syntax

I've tried to look everywhere for a solution, but can't find one.我试图到处寻找解决方案,但找不到。 What is it that I'm doing wrong?我做错了什么?

The correct get-pip.py file for python2 has been moved to https://bootstrap.pypa.io/pip/2.7/get-pip.py python2 的正确get-pip.py文件已移至https://bootstrap.pypa.io/pip/2.7/get-pip.py

PIP has dropped support for Python 2.7 in the result you are facing the above issue, so the only thing is to downgrade the version of pip. PIP 已经放弃了对 Python 2.7 的支持,结果您遇到了上述问题,所以唯一的办法就是降级 pip 的版本。

only the following command worked for me...只有以下命令对我有用......

sudo easy_install pip==20.3.4

This is what you need to do这是你需要做的

wget https://bootstrap.pypa.io/2.7/get-pip.py
python get-pip.py

Try installing previous version of get-pip尝试安装以前版本的 get-pip

wget https://bootstrap.pypa.io/3.5/get-pip.py wget https://bootstrap.pypa.io/3.5/get-pip.py

python get-pip.py python get-pip.py

I was getting this error with pip. pip 出现此错误。 This command worked for me sudo easy_install pip==20.3.4这个命令对我sudo easy_install pip==20.3.4

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

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