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

PythonWindows 7Pip

Python Problem Overview


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

Python Solutions


Solution 1 - Python

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

Solution 2 - Python

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

Solution 3 - Python

What solved the issue on my case was go to:

cd C:\Program Files\Python37\Scripts

And run below command:

easy_install.exe pip

Solution 4 - Python

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 

Solution 5 - Python

Follow steps given in https://michlstechblog.info/blog/python-install-python-with-pip-on-windows-by-the-embeddable-zip-file/. Replace x with version number of Python.

  1. Open the pythonxx.__pth file, located in your python folder.
  2. Edit the contents (e.g. D:\Pythonx.x.x to the following):
 D:\Pythonx.x.x 
 D:\Pythonx.x.x\DLLs
 D:\Pythonx.x.x\lib
 D:\Pythonx.x.x\lib\plat-win 
 D:\Pythonx.x.x\lib\site-packages

Solution 6 - Python

try to type pip3 instead pip. also for upgrading pip dont use pip3 in the command

python -m pip install -U pip

maybe it helps

Solution 7 - Python

turned out i had 2 versions of python on my laptop

both commands worked for me

python -m ensurepip
py -m ensurepip

both with another installation path

c:\tools\python\lib\site-packages
c:\program files (x86)\microsoft visual studio\shared\python36_64\lib\site-packages 

only the first path was in my %PATH% variable

Solution 8 - Python

Running these 2 commands helped me:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

python get-pip.py

Solution 9 - Python

The ensurepip module was added in version 3.4 and then backported to 2.7.9.

So make sure your Python version is at least 2.7.9 if using Python 2, and at least 3.4 if using Python 3.

Solution 10 - Python

I'v solved this error by setting the correct path variables

    C:\Users\name\AppData\Local\Programs\Python\Python37\Scripts
    C:\Users\name\AppData\Local\Programs\Python\Python37\Lib\site-packages

Solution 11 - Python

If you wrote

pip install --upgrade pip

and you got

Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.2.1
    Uninstalling pip-20.2.1:
ERROR: Could not install packages due to an EnvironmentError...

then you have uninstalled pip instead install pip. This could be the reason of your problem.

The Gorodeckij Dimitrij's answer works for me.

python -m ensurepip

Solution 12 - Python

I found this post while looking for a solution for the same problem. I was using an embedded python distribution. In this case, the solution is to uncomment import site in the file python<version>._pth.

Solution 13 - Python

I was facing same issue and resolved using following steps

  1. Go to your paython package and rename "python37._pth" to python37._pth.save

  2. curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

  3. then run python get-pip.py

  4. pip install django

Hope this help

Solution 14 - Python

I've solved this error downloading the executable file for python 3.7. I've had downloaded the embeddeable version and got that error. Now it works! :D

Solution 15 - Python

The method I'm going to tell might not be the correct way to do it. But this method solved my issue. I tried every solution on youtube and StackOverflow methods.

  1. If you have two python versions installed. Delete one. I have the python 3.8.1 and 3.9.0 versions installed. I deleted version 3.9.0 from the C directory.

  2. Now go to the control panel > System and security > System > Advanced system settings.

enter image description here

Click on 'environment variables'.

enter image description here

Select the path and click on 'edit'

Now, add the path of the python and also the path of pip module. In my case it was c:\python38 and c:\python38\scripts

This method solved my issue.

Solution 16 - Python

First make sure that python is added in environment variable.

Try checking the version of pip or pip3. Use these commands to check.

For pip:

pip --version

For pip3:

pip3 --version 

If you can see any version of pip and still not able to use it, then run the following command.

python -m ensurepip 

This ensures the pip in your system.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionDeval PandyaView Question on Stackoverflow
Solution 1 - PythonGorodeckij DimitrijView Answer on Stackoverflow
Solution 2 - PythonSky VoyagerView Answer on Stackoverflow
Solution 3 - PythonLucas Mota AlvesView Answer on Stackoverflow
Solution 4 - Pythonraven404View Answer on Stackoverflow
Solution 5 - PythonAmit PanasaraView Answer on Stackoverflow
Solution 6 - PythonSetmaxView Answer on Stackoverflow
Solution 7 - PythonSloomyView Answer on Stackoverflow
Solution 8 - PythonDeviljeeView Answer on Stackoverflow
Solution 9 - PythontwasbrilligView Answer on Stackoverflow
Solution 10 - PythonPratikPalView Answer on Stackoverflow
Solution 11 - PythonnegasView Answer on Stackoverflow
Solution 12 - PythoncanboooView Answer on Stackoverflow
Solution 13 - Pythonvaquar khanView Answer on Stackoverflow
Solution 14 - PythonGonzalo BlottaView Answer on Stackoverflow
Solution 15 - PythonTahil BansalView Answer on Stackoverflow
Solution 16 - PythonRajan GautamView Answer on Stackoverflow