Pip: ModuleNotFoundError: No module named 'pip._internal'

Created on 6 May 2018  ·  28Comments  ·  Source: pypa/pip

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

Most helpful comment

I hit the same snag and just reinstalled pip:

sudo easy_install pip

All 28 comments

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

Are the following different?

python3 -m pip --version
pip3 --version

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

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.

Maybe the following will work better?

pip3 install --user --upgrade pip

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

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

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

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

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

Thanks for filing this issue.

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?

@jesswren Have you tried in a new shell instance?

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

I hit the same snag and just reinstalled pip:

sudo easy_install pip

The above worked for me

sudo easy_install3 pip
worked for me

I my broken also.....

I fixed running command:

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

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

sudo apt remove python3-pip
worked for me

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

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

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.

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.

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

Also works for python2

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

Great! Thanks a lot!

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

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

sudo easy_install pip

Windows10 18.09
Python3.6.8
This worked for me

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

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

Worked for me

Was this page helpful?
0 / 5 - 0 ratings