Whenever I am trying to install any package using pip, I am getting this import error:
guru@guru-notebook:~$ pip3 install numpy
Traceback (most recent call l
you can simply fix the pip and pip3 paths using update-alternatives
first thing you should check is your current $PATH
run echo $PATH
and see is you can find /usr/local/bin
which is where pip3 and pip usually are
there is a change your system is looking here /bin/pip
and /bin/pip3
so i will say fix the PATH by adding to your ~/.bash_profile
file so it persists
export PATH=$PATH:/usr/local/bin
and then check is its fixed with which pip
and which pip3
if not then use update-alternatives
to fix it finally
update-alternatives --install /bin/pip3 pip3 /usr/local/bin/pip3 30
and if you want to point pip to pip3 then
update-alternatives --install /bin/pip pip /usr/local/bin/pip3 30
I'm running on a system where I have sudo apt but no sudo pip. (And no su access.) I got myself into this same situation by following the advice from pip:
You are using pip version 8.1.1, however 18.0 is available. You should consider upgrading via the 'pip install --upgrade pip' command.
None of the other fixes worked for me, because I don't have enough admin privileges. However, a few things stuck with me from reading up on this:
So, I found this command line to work to revert me back to where I was. If you were using a different version than 8.1.1, you will obviously want to change that part of the line.
python -m pip install --force-reinstall pip==8.1.1 --user
That's the only thing that worked for me, but it worked perfectly!
Same thing happened to me on Pixelbook using the new LXC (strech). This solution is very similar to the accepted one, with one subtle difference, whiched fixed pip3 for me.
sudo python3 -m pip install --upgrade pip
That bumped the version, and now it works as expected.
I found it here ... Python.org: Ensure pip is up-to-date
I had this same error, but python -m pip
was still working, so I fixed it with the nuclear option sudo python -m pip install --upgrade pip
. It did it for me.
You can resolve this issue by reinstalling pip.
Use one of the following command line commands to reinstall pip:
Python2:
python -m pip uninstall pip && sudo apt install python-pip --reinstall
Python3:
python3 -m pip uninstall pip && sudo apt install python3-pip --reinstall
For Python version 2.7 @Anthony solution works perfect, by changing python3 to python as follows:
sudo python -m pip uninstall pip && sudo apt install python-pip --reinstall