python-3.x pkg_resources.DistributionNotFound:未找到应用程序所需的“pip==20.0.2”发行版

km0tfn4u  于 2023-11-20  发布在  Python
关注(0)|答案(1)|浏览(317)
python --version
Python 2.7.18
python3 --version
Python 3.10.0

字符串
在我使用sudo apt-get install python3-pip安装pip3之后
我跑pip3
下面显示错误:

$ pip3
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 568, in _build_master
    ws.require(__requires__)
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 886, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 777, in resolve
    raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pip 21.2.3 (/usr/local/lib/python3.10/site-packages), Requirement.parse('pip==20.0.2'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/bin/pip3", line 6, in <module>
    from pkg_resources import load_entry_point
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3243, in <module>
    def _initialize_master_working_set():
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3226, in _call_aside
    f(*args, **kwargs)
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 3255, in _initialize_master_working_set
    working_set = WorkingSet._build_master()
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 570, in _build_master
    return cls._build_from_requirements(__requires__)
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 583, in _build_from_requirements
    dists = ws.resolve(reqs, Environment())
  File "/usr/local/lib/python3.10/site-packages/pkg_resources/__init__.py", line 772, in resolve
    raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==20.0.2' distribution was not found and is required by the application


如果有人能提供解决这个问题的任何想法,我将不胜感激
谢谢

lrl1mhuk

lrl1mhuk1#

在pip文档中强烈建议不要使用sudo运行pip,因为它会破坏你的系统。你应该使用你的发行版的包管理器升级你的系统pip(如果他们还没有最新版本的pip,这对你很重要,你需要向他们确认他们什么时候会打包它)。或者使用虚拟环境,这是推荐的方法。
https://discuss.python.org/t/help-needed-about-versionconflict-pkg-ressources/17991
这里讨论了许多解决方案:
git链接:https://github.com/pypa/pip/issues/5599#issuecomment-414157896
请看看哪一个适合你。

相关问题