Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do I get /usr/bin/python: No module named pip

Tags:

python

pip

When I do python -m pip install 'uwsgi==2.0.*'

I'm getting:

/usr/bin/python: No module named pip

which pip gives:

/home/snowcrash/.local/bin/pip

If I do pip I get:

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

This does not seem to help /usr/local/bin/python: No module named pip

like image 665
Snowcrash Avatar asked Apr 24 '26 05:04

Snowcrash


2 Answers

I had this error on Ubuntu when I don't use virtual environment, I tried to upgrade pip with this command but it didn't work.

/bin/python -m pip install --upgrade pip

So I used this command and issue is fixed.

sudo apt-get install python3-pip

If you don't use Ubuntu Python 3, you can use;

sudo apt-get install python-pip
like image 91
sglbl Avatar answered Apr 26 '26 18:04

sglbl


I don't know your exact situation, but this suggestions can be helpful:

To fix the No module named pip._internal.cli.main error

It seems like you have a broken pip. I mean, incomplete (and incompatible) parts of pip living in the same Python distribution, that generates... a useless pip. That's why you hit with those weird errors.

Something you can do is re-installing pip (from scratch). Consider tools like get-pip.py or python -m ensurepip. See the reference of this problem at this GitHub issue.

To fix the error with python -m pip

Also, you may have Python 2 installed in addition of Python 3. To verify that, run python --version. If you get a Python 2 version, try python3 --version. If you don't get errors (and receive a Python 3 version), replace python -m pip with python3 -m pip. That should fix your No module named pip issue. Also, you can run python3 -m ensurepip (or python -m ensurepip, if python3 doesn't exist).

However, if that doesn't work, maybe you will have to re-install the whole Python.

like image 44
Diego Ramirez Avatar answered Apr 26 '26 19:04

Diego Ramirez