Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I getting ImportError: No module named pip ' right after installing pip?

I have installed pip and ez setup. I also checked the system path and I can see the module in the folder structure. Still when i try to run pip command, I get an Import error saying no module named pip. I am running 32bit python on a windows7 machine

like image 717
Deval Pandya Avatar asked Sep 17 '15 20:09

Deval Pandya


3 Answers

Just be sure that you have include python to windows PATH variable, then run python -m ensurepip

like image 127
Gorodeckij Dimitrij Avatar answered Oct 12 '22 17:10

Gorodeckij Dimitrij


After running get_pip.py with python embed you have to modify your pythonXX._pth file. Add Lib\site-packages, to get something like this:

pythonXX.zip
.
Lib\site-packages
# Uncomment to run site.main() automatically
#import site

If you don't you will get this error:

ModuleNotFoundError: No module named 'pip'

or

python-3.8.2-embed-amd64\python.exe: No module named pip

λ pip
Traceback (most recent call last):
  File "runpy.py", line 193, in _run_module_as_main
  File "runpy.py", line 86, in _run_code
  File "python-3.8.2-embed-amd64\Scripts\pip.exe\__main__.py", line 4, in <module>
ModuleNotFoundError: No module named 'pip'

λ python -m pip
python-3.8.2-embed-amd64\python.exe: No module named pip
like image 34
Sky Voyager Avatar answered Oct 12 '22 17:10

Sky Voyager


This issue occurs with me while I was trying to upgrade pip version. It was resolved with the following commands:

python -m ensurepip

The above command restores the pip and below mentioned upgrades it.

python -m pip install --upgrade pip 
like image 38
raven404 Avatar answered Oct 12 '22 16:10

raven404