Python
pip 說它已過時,但更新說它是最新版本!
如果我嘗試執行以下操作:
pip --version
我明白了:
Traceback (most recent call last): File "/usr/bin/pip", line 6, in <module> from pkg_resources import load_entry_point File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3049, in <module> @_call_aside File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3033, in _call_aside f(*args, **kwargs) File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 3062, in _initialize_master_working_set working_set = WorkingSet._build_master() File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 660, in _build_master return cls._build_from_requirements(__requires__) File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 673, in _build_from_requirements dists = ws.resolve(reqs, Environment()) File "/usr/lib/python2.7/dist-packages/pkg_resources/__init__.py", line 858, in resolve raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'pip==9.0.3' distribution was not found and is required by the application
看起來 pip 已經過時了,所以我嘗試這樣做:
python -m pip install --upgrade pip
我明白了:
Requirement already up-to-date: pip in /usr/local/lib/python2.7/site-packages (10.0.1)
所以我很困惑!如何讓 pip 達到 pip 似乎需要的版本?
有關安裝的更多資訊,whereis 告訴我 pip 可在此處獲得:
pip: /usr/bin/pip /usr/local/bin/pip /usr/local/bin/pip2.7
和蟒蛇:
python: /usr/bin/python2.6-config /usr/bin/python2.6 /usr/bin/python2.7-config /usr/bin/python2.7 /usr/bin/python /usr/lib/python2.6 /usr/lib/python2.7 /usr/lib64/python2.6 /usr/lib64/python2.7 /usr/local/lib/python2.6 /usr/local/lib/python2.7 /usr/include/python2.6 /usr/include/python2.7 /usr/share/man/man1/python.1.gz
正如@Kusalananda 所說,/usr/bin 和 /usr/local/bin 中有多個版本的 pip。我通過創建從 /usr/bin 到 /usr/local/bin 中最新版本的符號連結解決了這個問題:
sudo ln -s /usr/local/bin/pip /usr/bin/pip
您可以使用符號連結或使用最新的 pip 版本安裝應用程序
/usr/local/bin/