pip: My pip is broken. _internal module cannot be imported.

Maintainer note: Anyone that still gets this issue please see #5599.


  • Pip version: 8.1.1
  • Python version: 2.7.12
  • Operating system: Ubuntu 16.04 (64 bit)

Description:

my pip is broken. it cannot update. It also complains error when just type pip.

What I’ve run:

pip

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

Also tried sudo pip or sudo su; pip, with same output.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 7
  • Comments: 23 (2 by maintainers)

Most upvoted comments

I just change the from pip._internal import main into from pip import main and Voila! Problem dismissed

By typing:

sudo apt remove python-pip

the problem disappears. Strange.

This solution works with me xD

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

or use sudo for the higher permission:

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

Of course, we can use python3 instead of python πŸ˜‰

Ref

sudo python -m pip install -U pip==8.0.1

As indicated by @mahxn0, I did:

sudo python -m pip install -U pip == 8.0.1

After this:

sudo pip install -U pip

And it’s working normally now πŸ˜‰

I had the same problem, so that I applied your strange method: sudo apt remove python-pip and it solved my problem as well. I think it is about the version difference. Because before I removed pip, I upgraded pip from 8 to 10. After I removed pip, I checked the version of pip and output showed that I have pip with version of 10. And problem disappeared πŸ˜ƒ @zchrissirhcz

It’s a bad idea to sudo pip install -U pip.

https://github.com/pypa/pip/issues/5599#issuecomment-414157896 solved for me

python -m pip uninstall pip

and then do

pip3 install --user PACKAGENAME

This solution works with me xD

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

or use sudo for the higher permission:

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

Of course, we can use python3 instead of python πŸ˜‰

Ref

I had to use the -H option to sudo for it work. sudo -H python get-pip.py --force-reinstall

This works for me in Python3 and Ubuntu 18.04.

Install pip3:

sudo python3 -m pip install -U pip==19.0.2

Upgrade pip3:

sudo pip3 install --upgrade pip

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

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

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

I’d suggest looking at #5599 as for the root cause of this issue, and for describing what fixes it.

hi the brothers excuse me I have a problem with my mac OS, I already have a Python version 2.7 and I installed version 3.6 but I still have the system that puts me 2.7 in my / Library and I do not know what to do I can not even install modules on my IDE

@PavelNiedoba In my case, I first update pip with pip, then remove python-pip package on Ubuntu with apt.