Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to fix ModuleNotFoundError: No module named 'pip._internal' with python source code installation

I have installed python3.7 on redhat machine by compiling source code but I have a problem when dealing with pip3. I have made this steps after installation:

sudo ln /usr/local/bin/python3.7 /usr/bin/python3

sudo ln /usr/local/bin/pip3.7 /usr/bin/pip3

python3 -- version gives Python 3.7.3

But I have this errors by running these commands :

python3 -m pip install requests

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

pip3 install requests

gives ModuleNotFoundError: No module named 'pip._internal'

like image 879
Wajih Katrou Avatar asked May 29 '19 12:05

Wajih Katrou


People also ask

How do I enable pip installation?

Step 1: Download the get-pip.py (https://bootstrap.pypa.io/get-pip.py) file and store it in the same directory as python is installed. Step 2: Change the current path of the directory in the command line to the path of the directory where the above file exists. Step 4: Now wait through the installation process.

Why is pip install not working in Python?

One of the most common problems with running Python tools like pip is the “not on PATH” error. This means that Python cannot find the tool you're trying to run in your current directory. In most cases, you'll need to navigate to the directory in which the tool is installed before you can run the command to launch it.


Video Answer


4 Answers

Try to reinstall the pip as follows :

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py --force-reinstall
like image 116
Harsha Biyani Avatar answered Oct 24 '22 09:10

Harsha Biyani


I have had the same issue, eventually found out the I have a version of pip install in C:\Program Files (x86)\Microsoft Visual Studio\Shared\anaconda and it was defaulting to this.

I identified this by using

python -m ensurepip --default-pip

In a command prompt.

Deleted the anaconda folder and it finally works!

like image 10
Laura Baker Avatar answered Oct 24 '22 08:10

Laura Baker


If you are on a Unix distribution update pip with sudo:

sudo python3 -m pip install --upgrade pip
like image 7
Antonio Avatar answered Oct 24 '22 08:10

Antonio


To update pip, run:

python -m pip install --upgrade pip
like image 2
Ebr Mo Avatar answered Oct 24 '22 08:10

Ebr Mo