我这样做是为了安装pip
:
apt-get install python3-pip
但是当我尝试使用该命令时出现此错误:
# pip3 install --upgrade pip
Traceback (most recent call last):
File "/usr/bin/pip3", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/pip/__init__.py", line 16, in main
from pip._internal.utils.entrypoints import _wrapper
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/utils/entrypoints.py", line 3, in <module>
from pip._internal.cli.main import main
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
当我这样做时,我收到了同样的消息pip3 --version
:
# pip3 --version
Traceback (most recent call last):
File "/usr/bin/pip3", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.5/dist-packages/pip/__init__.py", line 16, in main
from pip._internal.utils.entrypoints import _wrapper
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/utils/entrypoints.py", line 3, in <module>
from pip._internal.cli.main import main
File "/usr/local/lib/python3.5/dist-packages/pip/_internal/cli/main.py", line 60
sys.stderr.write(f"ERROR: {exc}")
^
SyntaxError: invalid syntax
我需要帮助来修复它。
答案1
你可以尝试:
$sudo apt-get autoremove
$sudo apt-get update
$sudo easy_install pip==20.3.4
然后,在使用 pip 安装包时,使用:
$sudo pip2 install <package>
但是,使用:
$sudo pip install <package>
可能仍会显示相同的错误消息。这更可能与不再支持某些 pip 版本有关。
该解决方案已在以下平台上测试:
Distributor
ID: Ubuntu
Description: Ubuntu 16.04.7 LTS
Release: 16.04
Codename: xenial
It was run on 32bit Chromenotebook