How to Fix: pip is not recognized as an internal or external command
After installing Python on Windows, when you try to add pip packages for the first time, you might encounter the following error: 'pip' is not recognized as an internal or external command
. Here’s how to fix it:
If pip is not recognized, it probably means that its directory has not been added to your PATH
variable. You can fix this issue by extending the PATH
system variable with the folder pip has been installed in.
Here are the steps you need to follow:
1. Open the Windows Command Line
Start a windows command line, if you haven’t already.
You can do that by pressing Windows key and the R key (⊞ Win + R). This opens the Run
dialog. Type cmd
in the Open
field and hit Enter.
2. Verify Your Python Installation
To make sure that Python is installed properly, run:
python --version
You should see something like:
Python 3.7.6
If instead you get an error here, consult the troubleshooting section.
3. Find the Python Installation Path
To make Windows aware of the location of the pip executable, you first need to find it yourself. The exact path depends on your Windows version, and your Python version as well.
To find the installation path, type:
where python
This should return the path of the Python folder, something similar to:
C:\Python37
4. Extend the PATH
System Variable
You can use the following command to make your system aware of the path of pip
:
set PATH=%PATH%;C:\Python37\Scripts
Adjust the above command according to the setup of your system: in place of C:\Python37\
use the path returned in Step 3.
Explanation
Your system checks for executables in a number of predefined folders. If an executable is not located in one of these folders Windows will not find it.
Windows gets this from the PATH
system variable. This variable contains a list of folders, separated by semicolons (;
). When you try to run a command, Windows will look for the executable in each of these folders, from first to last.
The above command appends the location of the pip executable to the end of this list.
5. Rerun pip
Now, that you updated your PATH
, you can try to run pip
again, it should be working without any issue.
If it does not, consult the troubleshooting section.
Alternative Workaround
If the above method does not work out for you, there is a possible alternative solution.
Pip can also be run as a Python module:
python -m pip
This is a bit cumbersome, but can be used to at least verify your pip installation.
Troubleshooting
It is possible that there is an issue with your pip installation, or with pip itself.
If you see an error message when running python --version
, try reinstalling Python.
If Python is installed properly, but python -m pip
throws an error, try to reinstall pip by running python -m ensurepip --default-pip
.
After fixing these, and making sure that both Python, and pip is properly installed, try to run pip again. If it still fails, go back to Step 1. and see if you can fix the PATH
system variable.