25

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'

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
Wajih Katrou
  • 366
  • 1
  • 3
  • 8

4 Answers4

40

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
Harsha Biyani
  • 7,049
  • 9
  • 37
  • 61
11

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!

Harsha Biyani
  • 7,049
  • 9
  • 37
  • 61
Laura Baker
  • 497
  • 5
  • 14
  • BTW, this is what fixed it for me on Amazon Linux after I upgraded from Python 3.6.2 to 3.7.6 – Raj Jul 14 '20 at 00:42
  • Goog solution. I had similar issue when tried to upgrade pip but installation failed due to missing permissions. The result was uninstalled actual version and failed upgrade to up-to-date version. – Ascorpio Nov 01 '20 at 11:08
  • I upgraded to 3.9 in a Mac. This helps me to identify the problem is from the old version of python. Uninstall the old version fixed my problem. – Renhuai Dec 25 '20 at 05:14
6

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

sudo python3 -m pip install --upgrade pip
Antonio
  • 2,848
  • 2
  • 15
  • 15
1

To update pip, run:

python -m pip install --upgrade pip
shreyasm-dev
  • 2,711
  • 5
  • 16
  • 34
Ebr Mo
  • 29
  • 3
  • Trying this, I get: `/usr/bin/python: No module named pip.__main__; 'pip' is a package and cannot be directly executed` – einpoklum Aug 23 '23 at 17:12