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

Created on 16 Apr 2018  ·  23Comments  ·  Source: pypa/pip

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:

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.

duplicate auto-locked

Most helpful comment

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

All 23 comments

By typing:

sudo apt remove python-pip

the problem disappears. Strange.

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

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

This solution worked for me as well, as my error traceback was identical. Thanks for sharing.

When I try to uninstall pip on fedora it tries to remove 377 packages. I'm sure this wold break whole system

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

I had the same problem but I've used the temporary fix mentioned in issue #5240. Soon after that, a new complain popped out, indicating an error in line 11.

Traceback (most recent call last):
File "/usr/local/bin/pip", line 11, in
sys.exit(main())
NameError: name 'main' is not defined

I've changed the last line, from

sys.exit(main())

to

sys.exit(_main())

and Voila! Problem dismissed.

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

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 ;)

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

please help me :'(

@kouamegerard the problem is the python package manager, the pip is broken. You need to remove and re-install pip, specially not the version 10.0. Try to search on google how to install a pip version (like 9.0) on mac OS, hope this helps.

@kouamegerard I would suggest you use a homebrew provided Python installation (brew install python after installing it from https://brew.sh).

Strange indeed! I typed "sudo apt remove python3-pip", and then ran pip3, and it has installed all the packages it wasn't able to install before....

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 hit this inside a Dockerfile (when installing python3.6 and python3-pip).
Removing this line RUN pip3 install --upgrade pip resolved the issue.

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

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 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

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 thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Was this page helpful?
0 / 5 - 0 ratings