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
型
如果有人能提供解决这个问题的任何想法,我将不胜感激
谢谢
1条答案
按热度按时间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
请看看哪一个适合你。