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 (m
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
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
try -
pip install -U pip
pip install -U setuptools
if editing __init__.py
doesnt help.
Try :
sudo easy_install pip
and then
sudo easy_install setuptools
It probably happends because of messed-up dependencies.
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.