31

1

I can't use pip and I don't know why.

The error I get is shown below:

 File "d:\python\lib\runpy.py", line 193, in _run_module_as_main return _run_code(code, main_globals, None, File "d:\python\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "D:\Python\Scripts\pip.exe\__main__.py", line 5, in <module> ModuleNotFoundError: No module named 'pip' 

If I try py -3.8 -m pip install I get D:\Python\python.exe: No module named pip.

If I use get-pip nothing happens.

If I try to upgrade pip nothing happens.

7
  • Did you re-install python and all tools ? Commented May 2, 2020 at 14:47
  • Did you try using pip3? Commented May 2, 2020 at 14:52
  • tafhim | no i don´t have re-install python and all tools maby i can find another way Commented May 2, 2020 at 15:07
  • yovel cohen | Yes i did Commented May 2, 2020 at 15:07
  • How did you install python? Was this error there from the beginning or did it appear after you did something specific? Commented May 2, 2020 at 15:43

6 Answers 6

61

Following pip installation, try this on Windows

py -m ensurepip --upgrade 

This command activates pip.

Ref. https://docs.python.org/3/library/ensurepip.html

After this you can upgrade

python -m pip install --upgrade pip 

or, on Windows

py -m pip install -U pip 
Sign up to request clarification or add additional context in comments.

8 Comments

C:\Users\Amir>python -m ensurepip C:\Users\Amir>python -m pip install --upgrade pip Nothing happened
Amir, call the python executable by its full pathname or add its installation directory to the system variable PATH.
I tried this and got, "no module named ensurepip"
python -m pip install --upgrade pip uninstalls pip for me lmao python pls .-. ERROR: Could not install packages due to an OSError: [WinError 5] Access is denied Uninstalling pip-22.0.4
@Snowcrash Why are you using Python2 when it is end-of-life? pip can upgrade itself, therefore why it is listed twice. And short-args with single dash vs two for long-opts are CLI semantics, not a Python issue... The Python installer "ensures Python"... Not all OS come with Pip installed, therefore why it needs "ensured" via code that it does come with.
|
18

I had the same problem. But in my case, when I was upgrading the pip version the new version stopped installing (upgrading) before the older version successfully uninstalled. After searching 4 or 5 sites I found:

python -m ensurepip 

I was able to use the pip command and also this:

python -m pip install --upgrade pip 

Comments

4

For Debian/Ubuntu/Linux Mint and derivatives users

Install pip using APT:

sudo apt install python3-pip 

Comments

3

I don't know what OS you are using and what errors you got when using get-pip, but I had similar issue on Ubuntu20 and this solved it:

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

Credit: @Benjamin's answer here: https://askubuntu.com/questions/1025189/pip-is-not-working-importerror-no-module-named-pip-internal

1 Comment

Or, you could apt install python3-pip ...
0

I had the same problem, but found that python -m ensurepip just told me that the pip scripts were already installed. So what I did was delete the 2 pip directories under C:\Users\[user_id]\AppData\Local\Programs\Python\Python38\Lib\site-packages, then run python -m ensurepip again. That fixed it for me.

Comments

0

Try this python -m pip install --upgrade pip

A suggestion, try to use anaconda or venv to avoid such issues.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.