pip: no module named _internal

2020-01-30 03:55发布

I have a problem when I try to use pip in any way. I'm using Ubuntu 16.04.4

I should say that I've used it already, and I never had any problem, but starting today when I use any command I always get the same error (as an example using pip --upgrade).

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

I have tried doing sudo apt-get remove python-pip followed by sudo apt-get install python-pip but nothing changed.

Thank you for your time!

标签: python pip
24条回答
可以哭但决不认输i
2楼-- · 2020-01-30 04:39

i tried the followed command to solve the issue and it worked for me curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py python3 get-pip.py --force-reinstall

查看更多
SAY GOODBYE
3楼-- · 2020-01-30 04:40

Are you using python2 or python3? The following command could be different!

  1. use python3 -m pip --version to see if you have pip installed.
  2. if yes, run python3 -m pip install --upgrade pip.
  3. if no, run sudo apt-get install python3-pip, and do it again.
查看更多
劳资没心,怎么记你
4楼-- · 2020-01-30 04:41

Refer to this issue list

sudo easy_install pip

works for me under Mac OS

For python3, may try sudo easy_install-3.x pip depends on the python 3.x version. Or python3 -m pip install --user --upgrade pip

查看更多
女痞
5楼-- · 2020-01-30 04:43

you can remove it first, and install again ,it will be ok. for centos:

yum remove python-pip
yum install python-pip
查看更多
爱情/是我丢掉的垃圾
6楼-- · 2020-01-30 04:43

For the current user only:

easy_install --user pip

or

python -m pip install --upgrade --user pip

The second may give /usr/bin/python: No module named pip Even if which pip finds the module named pip. In this case try the easy_install

查看更多
该账号已被封号
7楼-- · 2020-01-30 04:45

My solution is adding import pip to the script linked to the pip/pip3 commands.

Firstly, open the file (e.g. /usr/local/bin/pip) with your favorite text editor and the sudo mode. For example, I use sudo vim /usr/local/bin/pip to open the script file.

You will obtain some file as following:

import re
import sys

from pip._internal import main

if __name__ == '__main__':
    sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
    sys.exit(main())

Afterwards, insert the statement import pip just before the from pip._internal import main then the issue is resolved.

查看更多
登录 后发表回答