$ sudo -H pip3 install django~=1.11.0
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 666, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 984, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 875, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pip 8.1.1 (/usr/lib/python3/dist-packages), Requirement.parse('pip==9.0.1'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 3147, in <module>
@_call_aside
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 3131, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 3160, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 668, in _build_master
return cls._build_from_requirements(__requires__)
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 681, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/usr/local/lib/python3.5/dist-packages/pkg_resources/__init__.py", line 870, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==9.0.1' distribution was not found and is required by the application
答案1
通过 python 调用 pip 对我来说很有效,例如:
python3 -m pip install --upgrade pip==9.0.1
(或您在 中看到的任何版本Requirement.parse('pip==X.Y.Z')
)
答案2
您需要先升级pip:
pip3 install --upgrade pip
答案3
您收到以下错误消息:
'pip==9.0.1' distribution was not found and is required by the application
pip 9.0.1 是 pip 当前的最新版本。要将 pip3 升级到版本 9.0.1,请运行以下命令。
sudo -H pip3 install --upgrade pip
sudo -H pip3 install django==1.11 # latest django long term support release
这在我的系统上运行良好,系统安装有 pip3 9.0.1。结果如下所示。(如果这些命令不起作用,请将错误消息粘贴到您的问题中。)
Installing collected packages: django
Found existing installation: Django 1.10.5
Uninstalling Django-1.10.5:
Successfully uninstalled Django-1.10.5
Successfully installed django-1.11