錯誤提示
➜ ~ pip
Traceback (most recent call last):
File "/usr/bin/pip", line 11, in <module>
load_entry_point('pip==10.0.1', 'console_scripts', 'pip')()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 476, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2700, in load_entry_point
return ep.load()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2318, in load
return self.resolve()
File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2324, in resolve
module = __import__(self.module_name, fromlist=['__name__'], level=0)
File "/usr/lib/python3.6/site-packages/pip/_internal/__init__.py", line 42, in <module>
from pip._internal import cmdoptions
File "/usr/lib/python3.6/site-packages/pip/_internal/cmdoptions.py", line 16, in <module>
from pip._internal.index import (
File "/usr/lib/python3.6/site-packages/pip/_internal/index.py", line 20, in <module>
from pip._vendor.requests.exceptions import SSLError
ModuleNotFoundError: No module named 'pip._vendor.requests.exceptions'
問題分析
系統是Manjaro Linux,pip是通過包管理器pacman安裝的,這個應該是包管理器安裝的pip出現了問題。
解除安裝試試。看看能不能在安裝後換回包管理器版本的pip,因為這樣子系統很乾淨。
解決方案
- 解除安裝pip
sudo pacman -R python-pip
- 下載最新的pip原始碼包當前為10.0.1,
wget https://files.pythonhosted.org/packages/ae/e8/2340d46ecadb1692a1e455f13f75e596d4eab3d11a57446f08259dee8f02/pip-10.0.1.tar.gz
- 解壓
tar -zxvf pip-10.0.1.tar.gz && cd pip-10.0.1
- 安裝pip
sudo python3 setup.py install
- 安裝pip完成
如果你沒有系統潔癖,強迫症到這裡就完成了。
這樣子安裝的pip無法通過包管理器完成更新,每次需要手動更新。 - 解除安裝pip
sudo python -m pip uninstall pip
- 重新安裝pip
sudo pacman -S python-pip