How do I fix "pip"?
Asked Answered
P

6

19

I have python 3.8.0 (on a Windows PC)

When I try to run: pip install selenium I get the following error:

Fatal error in launcher: Unable to create process using '"c:\python38\python.exe" "C:\Python38\Scripts\pip.exe" install selenium': The system cannot find the file specified.

python pip install selenium and py pip install selenium both give me this error:

can't open file 'pip': [Errno 2] No such file or directory

pip3 install selenium:

Fatal error in launcher: Unable to create process using '"c:\python38\python.exe" error: "C:\Python38\Scripts\pip3.exe" install selenium': The system cannot find the file specified.

When I run: python -m pip --version I get:

pip 20.0.2 from C:\Users\<UserName>\AppData\Local\Programs\Python\Python38\lib\site-packages\pip (python 3.8)

I'm having the same problems trying to install django as well.

Printable answered 17/4, 2020 at 18:16 Comment(9)
Have you installed PIP? Is it in your PATH?Gates
Seems like you are sometimes forgetting the -m in python -m pip somecommand or py -m pip somecommand.Roaster
1. "python -m pip install django" worked. What is the use of "-m"?Printable
2. How would I make sure that PIP is in my PATH?Printable
Don't modify PATH. See the following for details: snarky.ca/why-you-should-use-python-m-pipRoaster
The documentation explains -m. Sorry can’t easily link am on mobile.Toady
docs.python.org/3/using/cmdline.htmlToady
If I was you, I'd uninstall current Python installation and I would re-install with 'install for all users' checked during installation and all the issues would be solved, pip would work like a charm. Or you can navigate to the Python installation folders Scripts folder and open a command prompt there and try running pip that way.Cortezcortical
You should be running CMD as admin when you're doing 'pip install' on Windows.Koressa
M
28

Try below command and it works for me:

python -m pip install -U --force pip

Above command will first uninstall pip from yours system if already installed and install a fresh version. Once done just type pip and press enter. You will see pip common commands and general options.

Now try to install any module as per your choice. For Example:

pip install sklearn

If installation begin means your issue has been resolved.

Marthena answered 6/10, 2020 at 17:22 Comment(0)
K
19

Your output: C:\Users\\AppData\Local\Programs\Python\Python38\lib\site-packages\pip , makes me think that you've messed-up your pip installation.

To recover do the following:

  • Run CMD as admin
  • Do a python -m pip install -U --force pip (this will fix your pip installation)
  • Then close the CMD and open another admin CMD to make sure you get the PATH updates effectively
  • Do pip install -U --force selenium

This should help to solve the issue.

Koressa answered 18/4, 2020 at 6:53 Comment(0)
W
0

I had the same problem and found the solution:

  1. First check whether pip installed or not , in command prompt try pip --version, you should get something like this - pip 22.0.4.

  2. if not installed (command not recognized) try to use install pip- using curl, try this command - curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

  3. then check again with pip --version

This website has detailed steps.

Wart answered 23/3, 2022 at 18:23 Comment(0)
A
0

Do in your terminal (fix your pip installation) 🖇️🔗 python -m pip install -U --force pip Then Do pip install -U --force selenium

Abuttal answered 8/8, 2022 at 19:33 Comment(1)
This is a duplicate of the answer with the most upvotes.Descendent
B
0

In my case, python version 3.12.3, I try uninstall and reinstall, it work

Besides, we can use py instead python

py -m pip install -U --force pip

another option is using pip3 instead

pip3 install -U scikit-learn scipy matplotlib

enter image description here

enter image description here

Bordiuk answered 19/5 at 15:58 Comment(0)
S
0

Found a way to fix it on another thread,

python -m ensurepip

this fixed the same error on my pc

Superdreadnought answered 26/7 at 13:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.