我在 Ubuntu 14.04 上更新了 pip,pip install pip --upgrade
但现在它坏了,说它需要 Python 3.5 或更高版本,但我有 Python 3.4。
我需要重新安装哪些软件包来修复 pip?
$ pip3 search youtube-dl
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 7, in <module>
from pip._internal.cli.main import main
File "/usr/local/lib/python3.4/dist-packages/pip/_internal/cli/main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "/usr/local/lib/python3.4/dist-packages/pip/_internal/cli/autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "/usr/local/lib/python3.4/dist-packages/pip/_internal/cli/main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "/usr/local/lib/python3.4/dist-packages/pip/_internal/cli/cmdoptions.py", line 28, in <module>
from pip._internal.models.target_python import TargetPython
File "/usr/local/lib/python3.4/dist-packages/pip/_internal/models/target_python.py", line 4, in <module>
from pip._internal.utils.misc import normalize_version_info
File "/usr/local/lib/python3.4/dist-packages/pip/_internal/utils/misc.py", line 20, in <module>
from pip._vendor import pkg_resources
File "/usr/local/lib/python3.4/dist-packages/pip/_vendor/pkg_resources/__init__.py", line 92, in <module>
raise RuntimeError("Python 3.5 or later is required")
RuntimeError: Python 3.5 or later is required
$ python3 --version
Python 3.4.3
$ python
python python2-jsondiff python3.4m-config python-mkdebian
python2 python2-jsonpatch python3-config pythontex
python2.7 python3 python3m pythontex3
python2.7-config python3.4 python3m-config
python2.7-pyrexc python3.4-config python-config
python2-config python3.4m python-html-css-webkit-hello-world.py
$ find /usr -maxdepth 4 -iname pip -type d
/usr/lib/python2.7/dist-packages/pip
/usr/lib/python3/dist-packages/pip
答案1
看起来您将 pip 升级到了不支持您的 Python 版本的版本。
卸载pip并重新安装系统pip:
sudo apt purge python-pip python3-pip
sudo rm -rf /usr/local/lib/python2.7/dist-packages/pip
sudo rm -rf /usr/local/lib/python3.4/dist-packages/pip
sudo apt install python-pip python3-pip
别跑pip install pip --upgrade
请注意,您使用的是不受支持的 Ubuntu 版本、不受支持的 Python 版本(如果是 Python 2)和几乎不受支持的 Python(3.4 EOL 2020 年 6 月)。您应该考虑升级到较新的 LTS。Ubuntu 16.04 会更进一步,18.04 会更好,或者等到下个月的 20.04。它们都带有现代 Python 3,并且从 18.04 开始默认不安装 Python 2。