What might be the problem below? It looks like there is a bug in pip.
I installed pip yesterday using brew. Prior to that, I had installed
most python packages with $ python setup.py install
steves-MacBook-Pro:server steve$ pip -V
pip 1.4.1 from /Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg (python 2.7)
steves-MacBook-Pro:server steve$ pip list
altgraph (0.9)
bdist-mpkg (0.4.4)
...
...(a bunch of python packages omitted here for brevity)
...
...
requests (2.0.0)
Exception:
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/basecommand.py", line 134, in main
status = self.run(options, args)
File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/commands/list.py", line 80, in run
self.run_listing(options)
File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/commands/list.py", line 127, in run_listing
self.output_package_listing(installed_packages)
File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/commands/list.py", line 136, in output_package_listing
if dist_is_editable(dist):
File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/util.py", line 347, in dist_is_editable
req = FrozenRequirement.from_dist(dist, [])
File "/Library/Python/2.7/site-packages/pip-1.4.1-py2.7.egg/pip/__init__.py", line 194, in from_dist
assert len(specs) == 1 and specs[0][0] == '=='
AssertionError
Using modern Ubuntu, I had the same problem and was able to fix it using the instructions in this comment.
The problem, as I understand it, is that pip as provided by Ubuntu is old, and also cannot update itself (since it's managed by apt, not pip). One solution is to remove the Ubuntu version of pip and install the latest.
In short:
sudo apt-get remove python-pip
wget https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py
This will install pip to /usr/local/bin, so you'll want to add that to your path.
This can be caused by an old version of pip.
Make sure your setuptools and pip are up to date:
sudo pip install --upgrade setuptools
sudo pip install --upgrade pip
Related
I tried to install a python package through pip, which raises a SyntaxError within setup.py:
$ /usr/bin/pip install dash --user
DEPRECATION: Python 2.6 is no longer supported by the Python core team, please upgrade your Python. A future version of pip will drop support for Python 2.6
Collecting dash
Using cached https://files.pythonhosted.org/packages/ad/94/c591c1ff695c32e7fc5138525f3a792d289160008f1a7f517860cc744a85/dash-0.26.5.tar.gz
Complete output from command python setup.py egg_info:
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/tmp/pip-build-ysGuJO/dash/setup.py", line 5, in <module>
exec(open('dash/version.py').read(), main_ns) # pylint: disable=exec-used
File "<string>", line 1
__version__ = '0.26.5'
^
SyntaxError: invalid syntax
----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-ysGuJO/dash/
You are using pip version 7.1.0, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
What am I doing wrong here? I suppose it has something todo with a too old python version:
$ python --version
Python 2.6.6
since the response is similar to this, more specific question on stackoverflow and
pip install urllib3
worked fine, which only requires >= Python 2.6.
This is a problem because of an older version of python. you might have to upgrade your python. After upgrading you won't be facing any issue.below are the step to upgrade. write the steps in your terminal.
# refreshing the repositories
sudo apt update
# its wise to keep the system up to date!
# you can skip the following line if you not
# want to update all your software
sudo apt upgrade
# installing python 2.7 and pip for it
sudo apt install python2.7 python-pip
# installing python-pip for 3.6
sudo apt install python3-pip
apt-get update
apt-get install python python-pip
python -m pip install --no-cache-dir setuptools==20.7.0
python -m pip install xxx
I tried to install a package through pip3, and I got this error. Every pip/pip3 command that I run gives me this error-
alexg#hitbox:~$ pip3 -V
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 7, in <module>
from pip import main
File "/home/alexg/.local/lib/python3.5/site-packages/pip/__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/home/alexg/.local/lib/python3.5/site-packages/pip/utils/__init__.py", line 27, in <module>
from pip._vendor import pkg_resources
File "/home/alexg/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3018, in <module>
#_call_aside
File "/home/alexg/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3004, in _call_aside
f(*args, **kwargs)
File "/home/alexg/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 3046, in _initialize_master_working_set
dist.activate(replace=False)
File "/home/alexg/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2578, in activate
declare_namespace(pkg)
File "/home/alexg/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2152, in declare_namespace
_handle_ns(packageName, path_item)
File "/home/alexg/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2092, in _handle_ns
_rebuild_mod_path(path, packageName, module)
File "/home/alexg/.local/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2121, in _rebuild_mod_path
orig_path.sort(key=position_in_sys_path)
AttributeError: '_NamespacePath' object has no attribute 'sort'
I have tried running pip3 install --upgrade pip setuptools according to some answers, but every pip command gives me the error. I'm stuck and can't do anything.
What could have caused it, and how can this be fixed?
I'm on Ubuntu 16.04 with Python 3.5.2
I met the same issue with python 3.5.2 and pip3 (9.0.1). And I fixed it by following this workaround: https://github.com/pypa/setuptools/issues/885#issuecomment-307696027
More specifically, I edited line #2121~2122 of this file: "sudo vim /usr/local/lib/python3.5/dist-packages/pip/_vendor/pkg_resources/__init__.py"
#orig_path.sort(key=position_in_sys_path)
#module.__path__[:] = [_normalize_cached(p) for p in orig_path]
orig_path_t = list(orig_path)
orig_path_t.sort(key=position_in_sys_path)
module.__path__[:] = [_normalize_cached(p) for p in orig_path_t]
Upgrading setuptools worked for me:
pip3 install --upgrade setuptools
This may sound weird, because I had this issue and I had tried everything mentioned in SO and GitHub issues. But then I installed pip with easyinstall and pip command is working. Maybe now there are 2 pip packages now. But error is gone.
easy_install pip
I'm using virtualenv and upgrading setuptools didn't work for me. What did work was this workaround:
pip uninstall setuptools -y && pip install setuptools
Yet another answer, but following is the one which eventually fixed the issue for me. Since pip was compromised I was unable to use it for upgrading itself or setuptools and also using easy_install was bringing up the same issue. So I tried to install pip using Python.
The answer:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
pip install --upgrade setuptools
try -
pip install -U pip
pip install -U setuptools
if editing __init__.py doesnt help.
I tried most of the above suggested solutions but nothing worked as pip3 was totally non-functional, then I found this:
https://deeptalk.lambdalabs.com/t/trying-to-uninstall-tensorflow-or-matplotlib-pip-package-throws-attributeerror--namespacepath-object-has-no-attribute-sort/310
I think this is probably the issue with most of us. I tried the suggested solution and pip3 is working again.
For me the matplotlib was not present in dist-packages but instead it was in site-packages, so the command that worked for me was:
sudo rm ~/.local/lib/python3.5/site-packages/matplotlib-3.0.3-py3.5-nspkg.pth
ofcourse you need to change the above path based on your version and location of matplotlib.
This probably means that your dependencies got messed up.
Try to uninstall pip3 from scratch and it should work.
In case it doesn't work, delete your pip installation. In your case:
rm -r /home/alexg/.local/lib/python3.5/site-packages/pip/
And to be sure next time, best to work with virtual environments :)
Try :
sudo easy_install pip
and then
sudo easy_install setuptools
It probably happends because of messed-up dependencies.
I had the same problem using poetry.
Running
poetry run pip install --upgrade pip setuptools
instead of
pip install --upgrade pip setuptools
fixed the issue.
I had this same problem, and was unable to run any command with pip3 (including any commands like pip3 install --upgrade pip setuptools).
Only fix I've found was to completely uninstall and re-install python 3 (sudo apt-get remove python3, sudo apt-get install python3, sudo apt install python3-pip) and now pip3 is working properly again.
After trying all kinds of methods, such as reinstall pip, setuptools, and still can't fix the problem.
I follow the instruction of https://github.com/pypa/pip/issues/4216#issuecomment-286348680 and only with an external warning.
After that, I use pip to uninstall matplotlib.
Finally, all things seem okay.
I had this problem consistently (and used the workaround below to use pip in the python3 interpreter). To my surprise, after uninstalling all versions of numpy and reinstalling the latest one, pip began working again. I can't say for sure what happened, but it might be something to try if everything else has failed.
The workaround (pieced together from several sources I don't recall) is
start python3
import pip twice (getting an error the first time)
use pip.main within the interpreter
Here is a transcript:
>>> import pip
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py",
__import__(vendored_name, globals(), locals(), level=0)
ImportError: No module named 'pip._vendor.pkg_resources'
During handling of the above exception, another exception occurred
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 13,
from pip.exceptions import InstallationError, CommandError, Pi
File "/usr/lib/python3/dist-packages/pip/exceptions.py", line 6,
from pip._vendor.six import iteritems
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", l
vendored("pkg_resources")
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", l
__import__(modulename, globals(), locals(), level=0)
.
etc
.
AttributeError: '_NamespacePath' object has no attribute 'sort'
>>> import pip
>>> pkgs = ['asciiplotlib']
>>> pip.main(['install'] + pkgs + ['--upgrade'])
Collecting asciiplotlib
Using cached https://files.pythonhosted.org/packages/15/c5/46a2d
Installing collected packages: asciiplotlib
Successfully installed asciiplotlib-0.1.8
I fixed this with follows:
$curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
For python2:
$python get-pip.py
For python3:
$python3 get-pip.py
Now it works for me.
None of the other posted answered worked for me, but running the follow command solved t:
sudo apt-get purge --auto-remove python3-pkg-resources python3-setuptools
This is for windows users, who installed WinPython
We couldn't even run pip command. Uninstall and install of Anaconda 3
We faced similar error. Finally we removed folder "Python" which is inside C:\Users\you\AppData\Roaming\ and removed folder "conda" & "packages" which is inside C:\Users\you\AppData\Roaming\conda.
Then it worked.
I used pip today for the first time in a while and I got the helpful message
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
So, I went ahead and
pip install --upgrade pip
but things did not go according to plan...
Collecting pip
Downloading pip-9.0.1-py2.py3-none-any.whl (1.3MB)
100% |████████████████████████████████| 1.3MB 510kB/s
Installing collected packages: pip
Found existing installation: pip 8.1.1
Uninstalling pip-8.1.1:
Exception:
Traceback (most recent call last):
File "//anaconda/lib/python2.7/site-packages/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "//anaconda/lib/python2.7/site-packages/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "//anaconda/lib/python2.7/site-packages/pip/req/req_set.py", line 726, in install
requirement.uninstall(auto_confirm=True)
File "//anaconda/lib/python2.7/site-packages/pip/req/req_install.py", line 746, in uninstall
paths_to_remove.remove(auto_confirm)
File "//anaconda/lib/python2.7/site-packages/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "//anaconda/lib/python2.7/site-packages/pip/utils/__init__.py", line 267, in renames
shutil.move(old, new)
File "//anaconda/lib/python2.7/shutil.py", line 303, in move
os.unlink(src)
OSError: [Errno 13] Permission denied: '/anaconda/lib/python2.7/site-packages/pip-8.1.1.dist-info/DESCRIPTION.rst'
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
And now it seems that pip is completely gone from my computer:
$ pip
-bash: //anaconda/bin/pip: No such file or directory
Is pip really gone, that is, did it really uninstall and then fail to reinstall, or did something just get unlinked? How can I avoid this issue in the future? Because I can imagine I will need to upgrade pip again at some point...
Python comes with a module for installing pip without needing to pull anything from the internet called ensurepip. It's pretty straightforward to use, just run the following in a terminal:
python -m ensurepip
From there you can upgrade pip to the latest the standard way. Additional documentation is available here https://docs.python.org/3/library/ensurepip.html.
You can reinstall pip with conda:
conda install pip
Looks like you need to have root rights:
sudo conda install pip
You can use curl to reinstall pip via the Python Packaging Authority website:
curl https://bootstrap.pypa.io/get-pip.py | python
I am trying to use pip 8 in a super computer where I don't have root access. After downloading pip from:
https://pip.pypa.io/en/stable/installing/
I do:
myname#edison04:~/software/pip> python get-pip.py --prefix=~/local_python_lib/
Collecting pip
Using cached pip-8.0.3-py2.py3-none-any.whl
Collecting wheel
Using cached wheel-0.29.0-py2.py3-none-any.whl
Installing collected packages: pip, wheel
Found existing installation: pip 1.5.4
Uninstalling pip-1.5.4:
Exception:
Traceback (most recent call last):
File "/tmp/tmplu5E1W/pip.zip/pip/basecommand.py", line 209, in main
status = self.run(options, args)
File "/tmp/tmplu5E1W/pip.zip/pip/commands/install.py", line 317, in run
prefix=options.prefix_path,
File "/tmp/tmplu5E1W/pip.zip/pip/req/req_set.py", line 725, in install
requirement.uninstall(auto_confirm=True)
File "/tmp/tmplu5E1W/pip.zip/pip/req/req_install.py", line 752, in uninstall
paths_to_remove.remove(auto_confirm)
File "/tmp/tmplu5E1W/pip.zip/pip/req/req_uninstall.py", line 115, in remove
renames(path, new_path)
File "/tmp/tmplu5E1W/pip.zip/pip/utils/__init__.py", line 266, in renames
shutil.move(old, new)
File "/usr/common/usg/python/2.7.9/lib/python2.7/shutil.py", line 300, in move
rmtree(src)
File "/usr/common/usg/python/2.7.9/lib/python2.7/shutil.py", line 247, in rmtree
rmtree(fullname, ignore_errors, onerror)
File "/usr/common/usg/python/2.7.9/lib/python2.7/shutil.py", line 252, in rmtree
onerror(os.remove, fullname, sys.exc_info())
File "/usr/common/usg/python/2.7.9/lib/python2.7/shutil.py", line 250, in rmtree
os.remove(fullname)
OSError: [Errno 13] Permission denied: '/global/common/edison/usg/python/2.7.5/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg/pip/__init__.py'
You are using pip version 1.5.4, however version 8.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
It tries to remove the already existing pip which I don't want to (and I don't have permissions to).... May I ask what can i do? Thank you.
A few more updates: adding --user does not help:
myname#edison04:~/software/pip> python get-pip.py --prefix=~/local_python_lib/ --user
ERROR: Can not combine '--user' and '--prefix' as they imply different installation locations
You are using pip version 1.5.4, however version 8.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
myname#edison04:~/software/pip> python get-pip.py --user
Collecting pip
Using cached pip-8.0.3-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-1.5.4
You are using pip version 1.5.4, however version 8.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
This installs pip-1.5.4 on some location, however I want to use pip 8.0.3 instead... Further more, when i locate the installed pip, and try to check their version... I think it just links my local bin to the pip 1.5.4 global bin
key01027#edison04:~> find . -name "pip"
./software/pip
./local_python_lib/pip
./.local/bin/pip
./.local/edison/2.7.9/lib/python2.7/site-packages/pip
./.local/edison/2.7.9/bin/pip
./.cache/pip
key01027#edison04:~> cd .local/
key01027#edison04:~/.local> cd bin/
key01027#edison04:~/.local/bin> ls
pip pip2 pip2.7
key01027#edison04:~/.local/bin> ./pip --version
pip 1.5.4 from /global/common/edison/usg/python/2.7.5/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg (python 2.7)
key01027#edison04:~/.local/bin> ./pip2 --version
pip 1.5.4 from /global/common/edison/usg/python/2.7.5/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg (python 2.7)
key01027#edison04:~/.local/bin> ./pip2.7 --version
pip 1.5.4 from /global/common/edison/usg/python/2.7.5/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg (python 2.7)
What could I do? Thank you
further, using virtual env also does not solve this problem:
After set up the virtualenv, it also does not help...
(dev)key01027#edison08:~/software> which pip
/global/homes/k/key01027/dev/bin/pip
(dev)key01027#edison08:~/software> pip install --upgrade pip
Cannot fetch index base URL https://pypi.python.org/simple/
Could not find any downloads that satisfy the requirement pip in /global/common/edison/usg/python/2.7.5/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg
Downloading/unpacking pip
Cleaning up...
No distributions at all found for pip in /global/common/edison/usg/python/2.7.5/lib/python2.7/site-packages/pip-1.5.4-py2.7.egg
Storing debug log for failure in /global/homes/k/key01027/.pip/pip.log
Python Virtual Environments solve this problem by allowing you to segment off your project's dependencies from others on the same system.
Most locked down systems still provide virtualenv, if not - contact your system administrator.
http://docs.python-guide.org/en/latest/dev/virtualenvs/
https://pypi.python.org/pypi/virtualenv
Whenever i try to use pip I get an error. For exampple:
$ sudo pip install gevent-websocket
Traceback (most recent call last):
File "/usr/local/bin/pip", line 5, in <module>
from pkg_resources import load_entry_point
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 2675, in <module>
parse_requirements(__requires__), Environment()
File "/usr/lib/python2.7/dist-packages/pkg_resources.py", line 552, in resolve
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: pip==0.8.1
I feel tempted to change the value of into pip==0.8.2.. but I dont feel dealing with the consequences of 'hacking' up my installation...
I'm running python 2.7 and pip is at version 0.8.2.
I find this problem in my MacBook, the reason is because as #Stephan said, I use easy_install to install pip, and the mixture of both py package manage tools led to the pkg_resources.DistributionNotFound problem.
The resolve is:
easy_install --upgrade pip
Remember: just use one of the above tools to manage your Py packages.
I replaced 0.8.1 in 0.8.2 in /usr/local/bin/pip and everything worked again.
__requires__ = 'pip==0.8.2'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('pip==0.8.2', 'console_scripts', 'pip')()
)
I installed pip through easy_install which probably caused me this headache.
I think this is how you should do it nowadays..
$ sudo apt-get install python-pip python-dev build-essential
$ sudo pip install --upgrade pip
$ sudo pip install --upgrade virtualenv
I had this issue when I was using homebrew. Here is the solution from Issue #26900
python -m pip install --upgrade --force pip
Try re-installing with the get-pip script:
wget https://bootstrap.pypa.io/get-pip.py
sudo python3 get-pip.py
This is sourced from the pip Github page, and worked for me.
If you're on CentOS make sure you have the YUM package "python-setuptools" installed
yum install python-setuptools
Fixed it for me.
The root of the problem are often outdated scripts in the bin (Linux) or Scripts (Windows) subdirectory. I'll explain this using problem I encountered myself as an example.
I had virtualenv version 1.10 installed in my user site-packages (the fact it's in user site-packages not sytem site-packages is irrelevant here)
pdobrogost#host:~$ which virtualenv
/home/users/pdobrogost/.local/bin/virtualenv
pdobrogost#host:~$ virtualenv --version
1.10
After I upgraded it to version 1.11 I got the following error:
pdobrogost#host:~$ virtualenv --version
Traceback (most recent call last):
File "/home/users/pdobrogost/.local/bin/virtualenv", line 5, in <module>
from pkg_resources import load_entry_point
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 2701, in <module>
return self.__dep_map
File "build/bdist.linux-x86_64/egg/pkg_resources.py", line 572, in resolve
if insert:
pkg_resources.DistributionNotFound: virtualenv==1.10
File /home/users/pdobrogost/.local/bin/virtualenv mentioned in the error message looked like this:
#!/opt/python/2.7.5/bin/python2.7
# EASY-INSTALL-ENTRY-SCRIPT: 'virtualenv==1.10','console_scripts','virtualenv'
__requires__ = 'virtualenv==1.10'
import sys
from pkg_resources import load_entry_point
if __name__ == '__main__':
sys.exit(
load_entry_point('virtualenv==1.10', 'console_scripts', 'virtualenv')()
)
There, we see that virtualenv script was not updated and still requires previously installed version 1.10 of virtualenv.
Now, reinstalling virtualenv like this
pdobrogost#host:~$ pip install --user --upgrade virtualenv
Downloading/unpacking virtualenv from https://pypi.python.org/packages/py27/v/virtualenv/virtualenv-1.11.1-py27-none-any.whl#md5=265770b61de41d34d2e9fdfddcdf034c
Using download cache from /home/users/pdobrogost/.pip_download_cache/https%3A%2F%2Fpypi.python.org%2Fpackages%2Fpy27%2Fv%2Fvirtualenv%2Fvirtualenv-1.11.1-py27-none-any.whl
Installing collected packages: virtualenv
Successfully installed virtualenv
Cleaning up...
does not help (neither pip install --user --upgrade --force-reinstall virtualenv) because script /home/users/pdobrogost/.local/bin/virtualenv is left unchanged.
The only way I could fix this was by manually removing virtualenv* scripts from /home/users/pdobrogost/.local/bin/ folder and installing virtualenv again. After this, newly generated scripts refer to the proper version of the package:
pdobrogost#host:~$ virtualenv --version
1.11
I was able to resolve this like so:
$ brew update
$ brew doctor
$ brew uninstall python
$ brew install python --build-from-source # took ~5 mins
$ python --version # => Python 2.7.9
$ pip install --upgrade pip
I'm running w/ the following stuff (as of Jan 2, 2015):
OS X Yosemite
Version 10.10.1
$ brew -v
Homebrew 0.9.5
$ python --version
Python 2.7.9
$ ipython --version
2.2.0
$ pip --version
pip 6.0.3 from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.3-py2.7.egg (python 2.7)
$ which pip
/usr/local/bin/pip
I was facing the similar problem in OSx. My stacktrace was saying
raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: setuptools>=11.3
Then I did the following
sudo pip install --upgrade setuptools
This solved the problem for me. Hope someone will find this useful.
On Mac OS X (MBP), the following (taken from another answer found herein) resolved my issues:
C02L257NDV33:~ jjohnson$ brew install pip
Error: No available formula for pip
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can:
sudo easy_install pip
C02L257NDV33:~ jjohnson$ sudo easy_install pip
Clearly the root cause here is having a secondary method by which to install python (in my case Homebrew). Hopefully, the people responsible for the pip script can remedy this issue since its still relevant 2 years after first being reported on Stack Overflow.
I had this problem because I installed python/pip with a weird ~/.pydistutils.cfg that I didn't remember writing. Deleted it, reinstalled (with pybrew), and everything was fine.
In my case (sam problem, but other packages) there was no version dependency. A sequence of pip uninstall and pip insstall did help.