I have a problem when I try to use pip in any way. I'm using Ubuntu 16.04.4

I should say that I've used it already, and I never had any problem, but starting today when I use any command I always get the same error (as an example using pip --upgrade).

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

I have tried doing sudo apt-get remove python-pip followed by sudo apt-get install python-pip but nothing changed.

Thank you for your time!

  • Did you attempt to upgrade or install a newer pip? /usr/local/bin/pip is not where python-pip or python3-pip install the command for system wide use... – Thomas Ward Apr 20 '18 at 12:16
  • Did you upgrade to pip 10? I think this is related to github.com/pypa/pip/issues/5221 – Byte Commander Apr 20 '18 at 12:20

I solved the problem. At first I noticed that there is no problem if i call python -m pip. Then i removed a file named pip under /usr/local/bin (I don't know why it was there), now everything is working as expected.

| improve this answer | |

I Ran:

python3 -m pip install --upgrade pip

pip install --upgrade pip

This fixed the problem for me.

| improve this answer | |
  • This worked for me. – piccolo Jan 24 '19 at 15:00

The Ubuntu packaged version of pip can be pretty old, which can lead to this issue if you end up with simultaneous installations of both pip<=9 (from Ubuntu, in /usr/bin) and pip>=10 (installed manually, in ~/.local or /usr/local/bin). One simple way to avoid this issue altogether is not to install pip system-wide at all, but only within each Python virtual environment:

$ python3 -m venv venv
$ . venv/bin/activate
(venv)$ pip install --upgrade pip
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.