Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

My pip is broken. _internal module cannot be imported. #5253

Closed
zchrissirhcz opened this issue Apr 16, 2018 · 23 comments
Closed

My pip is broken. _internal module cannot be imported. #5253

zchrissirhcz opened this issue Apr 16, 2018 · 23 comments
Labels
auto-locked Outdated issues that have been locked by automation resolution: duplicate Duplicate of an existing issue/PR

Comments

@zchrissirhcz
Copy link

zchrissirhcz commented Apr 16, 2018

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.

@zchrissirhcz
Copy link
Author

By typing:

sudo apt remove python-pip

the problem disappears. Strange.

@mgedmin
Copy link

mgedmin commented Apr 16, 2018

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

@earcz
Copy link

earcz commented Apr 21, 2018

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

@aamick01
Copy link

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

@PavelNiedoba
Copy link

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

@zchrissirhcz
Copy link
Author

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

@PetreVane
Copy link

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.

@Shuailong
Copy link

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

@mahxn0
Copy link

mahxn0 commented May 16, 2018

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

@erijonhson
Copy link

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

@kouamegerard
Copy link

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

@kouamegerard
Copy link

please help me :'(

@DanielLSM
Copy link

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

@pradyunsg
Copy link
Member

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

@pradyunsg pradyunsg added the resolution: duplicate Duplicate of an existing issue/PR label Jun 11, 2018
@bobeobibo
Copy link

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

@abdallahokasha
Copy link

abdallahokasha commented Jun 29, 2018

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

@yegorski
Copy link

I hit this inside a Dockerfile (when installing python3.6 and python3-pip).
Removing this line RUN pip3 install --upgrade pip resolved the issue.

@pradyunsg
Copy link
Member

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

@ericoporto
Copy link

#5599 (comment) solved for me

python -m pip uninstall pip

and then do

pip3 install --user PACKAGENAME

@mrroot5
Copy link

mrroot5 commented Feb 19, 2019

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

@cdutr
Copy link

cdutr commented Mar 11, 2019

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

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

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

@yebo29
Copy link

yebo29 commented Mar 13, 2019

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

@lock
Copy link

lock bot commented May 28, 2019

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.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation resolution: duplicate Duplicate of an existing issue/PR
Projects
None yet
Development

No branches or pull requests