Pip is not working: ImportError: No module named 'pip._internal'

Running pip or pip3 results with:

Traceback (most recent call last):
File "/home/myuser/.local/bin/pip", line 7, in <module>
from pip._internal import main
ImportError: No module named 'pip._internal'

I had issues with this, and uninstalled pip3, but when i try to install it again using

sudo apt-get -y install python3-pip

it does install, but then running pip or pip3 i get the same error.

#which pip3
/home/myuser/.local/bin/pip3

After upgrading pip (or pip3, in this case) if the following occurs:

$ ~ pip3 -V
Traceback (most recent call last):
  File "/usr/local/bin/pip", line 7, in <module>
    from pip._internal import main
ModuleNotFoundError: No module named 'pip._internal'

Force a reinstall of pip:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall

Verify install:

$ ~ pip3 -V
pip 10.0.1 from /usr/local/lib/python3.6/site-packages/pip (python 3.6)

Now pip3 install <package> and pip3 install --user <package> (for user-level installs) will work correctly.

There should never, ever be any reason you need to run pip in elevated mode.

For Python 2.7

curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
python get-pip.py --force-reinstall

Had same problem on macOS as well, it's a common issue across platforms.


I solved this by updating pip via Python, like this:

python2 -m pip install --user --upgrade pip
python3 -m pip install --user --upgrade pip