pip 说它已经过时,但更新说它是最新版本!

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

答案1

正如 @Kusalananda 所说, /usr/bin 和 /usr/local/bin 中有多个版本的 pip 。我通过创建从 /usr/bin 到 /usr/local/bin 中的最新版本的符号链接解决了这个问题:

sudo ln -s /usr/local/bin/pip /usr/bin/pip

答案2

您可以使用符号链接或使用最新的 pip 版本安装应用程序/usr/local/bin/

相关内容