After upgrading pip, it no longer works - python

I recently updated my Homebrew installation of Python 3.8.2 to 3.8.3. After doing so, I ran
$ pip3 install -U pip
in order to check for any pip updates. It updated my installation of pip from 20.0.2 to 20.1.1, and ever since I ran that command, pip throws an error any time I try to use it. Here's the error:
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 584, in _build_master
ws.require(__requires__)
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 901, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 792, in resolve
raise VersionConflict(dist, req).with_context(dependent_req)
pkg_resources.VersionConflict: (pip 20.1.1 (/usr/local/lib/python3.8/site-packages), Requirement.parse('pip==20.0.2'))
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/opt/python#3.8/bin/pip3", line 6, in <module>
from pkg_resources import load_entry_point
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3255, in <module>
def _initialize_master_working_set():
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3238, in _call_aside
f(*args, **kwargs)
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 3267, in _initialize_master_working_set
working_set = WorkingSet._build_master()
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 586, in _build_master
return cls._build_from_requirements(__requires__)
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 599, in _build_from_requirements
dists = ws.resolve(reqs, Environment())
File "/usr/local/lib/python3.8/site-packages/pkg_resources/__init__.py", line 787, in resolve
raise DistributionNotFound(req, requirers)
pkg_resources.DistributionNotFound: The 'pip==20.0.2' distribution was not found and is required by the application
It seems that something went wrong during the upgrade process that failed to change the version check within the code. I saw this similar question, but the accepted answer is not working for me. How can I make pip usable again?

As per Python documentation, the correct way to use pip now would be via the correct Python executable, e.g.
python3 -m pip install -U pip

I had experienced a similar problem on my Ubuntu and here's how I solved my problem:
First restore the older version by reinstalling it from your OS package manager (You may need to uninstall first).
Upgrade to the latest version for your user (as opposed to installing in a system location) with the following command
pip3 install --user -U pip
Hope this helps.

Related

Python pip install error

I have just installed Python 3.4.3 on my MAC (Yosemite). I need to install a couple of lxml, however everytime I type in: pip install /""/, I get error messages.
I have followed multiple tutorials and pip is installed.
MAC already had Python 2.7., but I installed the 3.4.3. version, not sure if that is the issue.
The error message is:
Brunos-MacBook-Pro:~ BrunoPaesLeme$ pip install /Macintosh HD/Users//Downloads/pycairo-1.10.0-cp27-none-win_amd64.whl
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/commands/install.py", line 268, in run
wheel_cache
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/basecommand.py", line 268, in populate_requirement_set
wheel_cache=wheel_cache
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_install.py", line 207, in from_line
wheel_cache=wheel_cache)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/req/req_install.py", line 66, in init
req = pkg_resources.Requirement.parse(req)
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/_vendor/pkg_resources/init.py", line 2960, in parse
reqs = list(parse_requirements(s))
File "/Library/Python/2.7/site-packages/pip-7.0.3-py2.7.egg/pip/_vendor/pkg_resources/init.py", line 2891, in parse_requirements
raise ValueError("Missing distribution spec", line)
ValueError: ('Missing distribution spec', '/Macintosh')
Anybody knows what I could be doing wrong? Any help would be appreciated.
try:
easy_install pip
pip install /"filepath"/
I have similar issue with pip install. However, if I do "sudo su -" then do my pip install 'fileName', that solve the problem for me.

fig throws exception after installation

I installed fig on Arch Linux using the following command sudo pip install -U fig. After the installation was completed, I've tried to run fig --version but this gave me following errors:
Traceback (most recent call last):
File "/usr/bin/fig", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 2880, in <module>
working_set = WorkingSet._build_master()
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 432, in _build_master
ws.require(__requires__)
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 741, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/site-packages/pkg_resources.py", line 626, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: fig==1.0.1
As it can be seen in the errors, I use python2. I also tried using python3, but I've got the same error.
Can anyone give me a hint?
You can try upgrading pip with easy_install:
easy_install --upgrade pip
Then try reinstalling fig.
I installed fig when python3 with set as default. After setting python2 as default, I've reinstalled fig and everything works now.

getting DistributionNotFound error, but package exists

I am running pyjade for Django templates as I find it much easier to write in, but I am trying to convert it to html with the built in converter. When I run pyjade -c django input.jade output.html I get the error pkg_resources.DistributionNotFound: six. However, the package six does in fact exist, and I can import it on python, and when I run pip install six --upgrade it says it is already up-to-date.
Here is the full traceback:
Traceback (most recent call last):
File "/usr/local/bin/pyjade", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2707, in <module>
working_set.require(__requires__)
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 686, in require
needed = self.resolve(parse_requirements(requirements))
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 584, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: six
What would be causing this error?
Re-install via easy_setup (vs pip) solved it for me on OS X Mavericks:
sudo easy_install six
Hope that helps you!
An old setuptools was my culprit.
pip install -U setuptools

broken easy_install and pip after upgrading to OS X Mavericks

Upgraded to OS X 10.9 Mavericks and installed XCode, Command Line Tools, XQuartz, etc. Trying to run a pip install now, but it says that the distribution is not found:
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2603, in <module>
working_set.require(__requires__)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: pip==1.4.1
So I tried to install pip with an easy_install. Turns out that's borked too:
Traceback (most recent call last):
File "/usr/local/bin/easy_install", line 5, in <module>
from pkg_resources import load_entry_point
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 2607, in <module>
parse_requirements(__requires__), Environment()
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: setuptools==1.1.6
So some of the other threads say to reinstall setuptools with a sudo python ez_setup.py. It seems to work fine:
Installed /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/setuptools-1.1.6-py2.7.egg
Processing dependencies for setuptools==1.1.6
Finished processing dependencies for setuptools==1.1.6
But when running the easy_install pip, the same pkg_resources.DistributionNotFound: setuptools==1.1.6 error occurs. Anyone else have this problem? Any ideas how to fix this?
Install easy_install:
Download ez_setup.py module from https://pypi.python.org/pypi/setuptools
$ cd path/to/ez_setup.py
$ python ez_setup.py
Install pip:
$ sudo easy_install pip
try sudo python -m easy_install pip
I ran into a similar problem with git-review.
$ git review -s
Traceback (most recent call last):
File "/usr/local/bin/git-review", line 11, in <module>
sys.exit(main())
File "/Library/Python/2.7/site-packages/git_review/cmd.py", line 1132, in main
(os.path.split(sys.argv[0])[-1], get_version()))
File "/Library/Python/2.7/site-packages/git_review/cmd.py", line 180, in get_version
provider = pkg_resources.get_provider(requirement)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 197, in get_provider
return working_set.find(moduleOrReq) or require(str(moduleOrReq))[0]
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 666, in require
needed = self.resolve(parse_requirements(requirements))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/pkg_resources.py", line 565, in resolve
raise DistributionNotFound(req) # XXX put more info here
pkg_resources.DistributionNotFound: git-review
The git-review team said it was a bug with pkg_resources that could be fixed with
sudo pip install --upgrade setuptools
This worked fine for me.

Pytest Version Conflict Error

After update of Debian (Jessie), pytest doesn't work :
#py.test
Traceback (most recent call last):
File "/usr/bin/py.test", line 5, in <module>
sys.exit(load_entry_point('pytest==2.4.2', 'console_scripts', 'py.test')())
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 348, in load_entry_point
return get_distribution(dist).load_entry_point(group, name)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2311, in load_entry_point
return ep.load()
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2024, in load
if require: self.require(env, installer)
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 2037, in require
working_set.resolve(self.dist.requires(self.extras),env,installer)))
File "/usr/local/lib/python2.7/dist-packages/pkg_resources.py", line 571, in resolve
raise VersionConflict(dist,req) # XXX put more info here
pkg_resources.VersionConflict: (py 1.4.15 (/usr/lib/python2.7/dist-packages), Requirement.parse('py>=1.4.17'))
How can I fix this error? Thanx in advance!
The files in /usr/local/lib/python2.7/dist-packages belong to python packages you installed with pip, easy_install or python setup.py. The system update probably messed up some dependencies. Does this work?
sudo apt-get install python-pip
sudo /usr/bin/pip install -U pytest
Some instances might have more than one pytest running.
Try:
sudo apt-get remove pytest
Then run your test again.

Categories

Resources