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

ModuleNotFoundError: No module named 'pip._internal' #5373

Closed
suuuehgi opened this issue May 6, 2018 · 28 comments
Closed

ModuleNotFoundError: No module named 'pip._internal' #5373

suuuehgi opened this issue May 6, 2018 · 28 comments
Labels
auto-locked Outdated issues that have been locked by automation

Comments

@suuuehgi
Copy link

suuuehgi commented May 6, 2018

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


  • Pip version: 10.0.1
  • Python version: 3.6.5-2
  • Operating system: 4.16.3-1-ARCH

Description:

sudo pip install --upgrade pip using 9.0.1-3.

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

What (other) I've run:

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

# Back to 9.0.1-3
pacman -Sy --force python-pip
pip uninstall pip
python3 get-pip.py
@pradyunsg
Copy link
Member

Similar to #5221. The installed OS installed pip is doing something weird.

Are the following different?

python3 -m pip --version
pip3 --version

@suuuehgi
Copy link
Author

suuuehgi commented May 6, 2018

@pradyunsg They are equal for the repo version 9.0.1

$ python3 -m pip --version
pip 9.0.1 from /usr/lib/python3.6/site-packages (python 3.6)

$ pip3 --version
pip 9.0.1 from /usr/lib/python3.6/site-packages (python 3.6)

and different for 10.0.1:

$ sudo pip install --upgrade pip
Cache entry deserialization failed, entry ignored
Collecting pip
  Using cached https://files.pythonhosted.org/packages/0f/74/ecd13431bcc456ed390b44c8a6e917c1820365cbebcb6a8974d1cd045ab4/pip-10.0.1-py2.py3-none-any.whl
Installing collected packages: pip
  Found existing installation: pip 9.0.1
    Uninstalling pip-9.0.1:
      Successfully uninstalled pip-9.0.1
Successfully installed pip-10.0.1

$ python3 -m pip --version
/usr/bin/python3: No module named pip.__main__; 'pip' is a package and cannot be directly executed

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

@pradyunsg
Copy link
Member

You shouldn't be doing sudo pip. https://stackoverflow.com/questions/21055859/what-are-the-risks-of-running-sudo-pip

Looking at this, it seems to be an issue of trying to use pip to modify what your OS package manager has installed (through the use of sudo). It's likely that is why things are breaking here.

@pradyunsg
Copy link
Member

pradyunsg commented May 6, 2018

Maybe the following will work better?

pip3 install --user --upgrade pip

@simon2x
Copy link

simon2x commented May 9, 2018

I got the same error from upgrading pip

I removed pip3 files from /usr/local/bin/

and pip folder from /usr/local/lib/python3.5/dist-packages

and uninstalled python3-pip, before reinstalling

and it works again

@pradyunsg
Copy link
Member

@swprojects Your issue sounds like a distribution specific packaging issue. I request you to open an issue with your Linux Distribution and ask them to look into it.

Thanks!

@pradyunsg pradyunsg added the S: awaiting response Waiting for a response/more information label May 9, 2018
@RonnyPfannschmidt
Copy link
Contributor

the pip3 command is distribution managed - pip is completely unaware of it

in general upgrading a distribution managed pip using pip is an act of vandalism and any following breakage is on the vandal who inflicted the issue

@simon2x
Copy link

simon2x commented May 10, 2018

Yeah I made the mistake of thinking a pip upgrade would be aware of distribution managed pip. But lesson learned!

@pradyunsg
Copy link
Member

@swprojects It will be in the next release of pip. :)

Thanks for filing this issue.

@pradyunsg pradyunsg removed the S: awaiting response Waiting for a response/more information label May 10, 2018
@jesswren
Copy link

I am having the same problem here with pip ... I tried what swprojects suggested, and after reinstall, I now get the following error:

jess@debian:~$ pip
bash: /usr/local/bin/pip: No such file or directory

How do I fix this?

@pradyunsg
Copy link
Member

@jesswren Have you tried in a new shell instance?

@simon2x
Copy link

simon2x commented May 22, 2018

@jesswren did you try pip3 and not just pip?

Installing python3-pip is for python3, then command is pip3.

Likewise, if python2 then install python-pip, then command is pip.

edit: may not be that, but ubuntu prompts the user to install pip if it is not installed. Not sure if debian does the same thing.

@duhaime

This comment has been minimized.

@AdeyinkaAdegbenro
Copy link

The above worked for me

@etemiz
Copy link

etemiz commented Jul 7, 2018

sudo easy_install3 pip
worked for me

@marcuxyz
Copy link

marcuxyz commented Sep 6, 2018

I my broken also.....

I fixed running command:

└─ $ ▶ sudo pacman -S --force --noconfirm python-pip

wouterdb added a commit to inmanta/inmanta-core that referenced this issue Sep 19, 2018
related to pypa/pip#5373

- fixes #727 by using `python -m pip` instead of `pip`
- fixes bug where output is not printed upon failure of pip
wouterdb added a commit to inmanta/inmanta-core that referenced this issue Sep 25, 2018
related to pypa/pip#5373

- fixes #727 by using `python -m pip` instead of `pip`
- fixes bug where output is not printed upon failure of pip
@MrCrap
Copy link

MrCrap commented Nov 30, 2018

  • Pip version: 10.0.1
  • Python version: 3.6.5-2
  • Operating system: 4.16.3-1-ARCH

Description:

sudo pip install --upgrade pip using 9.0.1-3.

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

What (other) I've run:

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

# Back to 9.0.1-3
pacman -Sy --force python-pip
pip uninstall pip
python3 get-pip.py

Works for me, Thanks.

@celdeldel
Copy link

sudo apt remove python3-pip
worked for me

@xanfus
Copy link

xanfus commented Jan 17, 2019

pip3 has been reinstalled into /usr/bin/. I've pointed shell there to call for pip, which has executed nominally then.

@yurmchg
Copy link

yurmchg commented Feb 4, 2019

This worked for me:
python3 -m pip install --user --upgrade pip

@bwu62
Copy link

bwu62 commented Feb 6, 2019

This worked for me:
python3 -m pip install --user --upgrade pip

THANK YOU! My pip broke suddenly for no apparent reason the other week and I've tried googling all kinds of error messages and troubleshooting and uninstalling and reinstalling. This is the only thing that's worked.

@jerryrelmore
Copy link

I had the same issue ImportError: No module named 'pip._internal' when there were multiple versions of pip installed (likely one from distro repo and another via direct install). Simply removing one of the extra installed directories was enough to alleviate pip's confusion.

@cdutr
Copy link

cdutr commented Mar 11, 2019

This worked for me:
python3 -m pip install --user --upgrade pip

Also works for python2

@ks7000
Copy link

ks7000 commented Mar 14, 2019

This worked for me:
python3 -m pip install --user --upgrade pip

Great! Thanks a lot!

@bandaangosta
Copy link

What works for me, albeit in a Python 2.7-only restricted environment, is to modify "my" virtualenv pip as follows.
In venv/bin/pip change:
from pip._internal import main
to
from pip import main

@EilenC
Copy link

EilenC commented Apr 27, 2019

我遇到了同样的障碍,只是重新安装了点子:

sudo easy_install pip

Windows10 18.09
Python3.6.8
This worked for me

@solletravinder
Copy link

Similar to #5221. The installed OS installed pip is doing something weird.

Are the following different?

python3 -m pip --version
pip3 --version

version difference makes difference in calls. latest version can use pip3 install <package_name>

@malikalamgirian
Copy link

malikalamgirian commented May 25, 2019

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

Worked for me

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 24, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 24, 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
Projects
None yet
Development

No branches or pull requests