近日在使用pip时终端始终提示
You are using pip version 8.1.1, however version 21.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
于是手贱给升级了一下,然后再运行pip指令时始终产生如下报错
Traceback (most recent call last):
File "/home/huiyulin/.local/bin/pip", line 7, in <module>
from pip._internal.cli.main import main
File "/home/huiyulin/.local/lib/python2.7/site-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
网上多位博主给出的解决方法是
wget https://bootstrap.pypa.io/2.7/get-pip.py
python get-pip.py
但是该网址现在已经失效,执行如上指令后会得到开发者的一封信
Hi there!
The URL you are using to fetch this script has changed, and this one will no
longer work. Please use get-pip.py from the following URL instead:
https://bootstrap.pypa.io/pip/2.7/get-pip.py
Sorry if this change causes any inconvenience for you!
We don't have a good mechanism to make more gradual changes here, and this
renaming is a part of an effort to make it easier to us to update these
scripts, when there's a pip release. It's also essential for improving how we
handle the `get-pip.py` scripts, when pip drops support for a Python minor
version.
There are no more renames/URL changes planned, and we don't expect that a need
would arise to do this again in the near future.
Thanks for understanding!
- Pradyun, on behalf of the volunteers who maintain pip.
尝试了各种方法之后,发现最佳的解决方法是
sudo easy_install pip==20.3.4
下载完成后,使用pip --version查看pip版本,即可看到版本为20.3.4,不会再产生报错。