python - pip is not working after upgrade

懵懂的女人 提交于 2020-11-30 09:09:43

问题


I tried upgrade pip3 with this command:

sudo pip3 install --upgrade pip

but unfortunately it doesn't work anymore and shows this message:

pip3 --version

message:

Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/init.py", line 651, in _build_master ws.require(requires)
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/init.py", line 952, in require needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/init.py", line 844, in resolve raise VersionConflict(dist, req).with_context(dependent_req) pkg_resources.VersionConflict: (pip 7.1.2 (/usr/local/lib/python3.4/dist-packages), Requirement.parse('pip==1.5.6'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/bin/pip3", line 5, in from pkg_resources import load_entry_point
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/init.py", line 3084, in @_call_aside
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/init.py", line 3070, in _call_aside f(*args, **kwargs)
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/init.py", line 3097, in _initialize_master_working_set working_set = WorkingSet._build_master()
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/init.py", line 653, in _build_master return cls._build_from_requirements(requires)
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/init.py", line 666, in _build_from_requirements dists = ws.resolve(reqs, Environment())
File "/usr/local/lib/python3.4/dist-packages/pkg_resources/init.py", line 839, in resolve raise DistributionNotFound(req, requirers) pkg_resources.DistributionNotFound: The 'pip==1.5.6' distribution was not found and is required by the application

How to fix it?


回答1:


It seems like you don't use virtualenv and your pythons/paths are probably messed up. I faced with similar problem with python-2.7 and -3.4 on Ubuntu 14.04. I tried

sudo python -m pip install --upgrade --force-reinstall pip

for 2.7 and it helped. Then I reinstalled pip for python-3.4 via easy_install3.



来源:https://stackoverflow.com/questions/32565303/python-pip-is-not-working-after-upgrade

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!