According to Statista, Python is the 4th most used programming language in the world (in 2022). Programmers often install it on their Windows computers to develop applications. However, we have seen users report that they often encounter trouble when trying to install or modify the Python packages using the “PIP” command.
The most common error reported amongst developers is the following:
Pip is not recognized as an internal or external command.
The Pip Installation Packages (PIP) is a Python package management system used to install and manage its software packages. However, while using it to perform certain tasks, like installing another package using the command “pip install Django”, the aforementioned error is encountered.
In this post, we are going to address this issue so that you may continue with your Python development as planned.
Table of Contents
Why is Pip Command Not Found in Windows
When a user encounters the “Pip is not recognized as an internal or external command” error, it is due to one of the following reasons:
- Pip has not been added to the environment variables.
- The pip environment variable has incorrect values.
Environment variables are variables that can be used across your system. Just like in programming, variables contain a value that can be changed or called when needed. Environment variables are the same, but can be used across the entire scope.
When pp is not recognized, it is probably because the command line is unable to call on the actual program because of the missing or incorrect path.
Let us show you how to check whether a path for “pip” is present inside the Windows environment variables list.
How to Check Environment Variable for Pip
The most convenient method to check that pip was added to the PATH variable is using the Command Prompt. Follow these steps to check whether it is present or not:
-
Launch an elevated Command Prompt.
-
Run the following cmdlet:
echo %PATH%
-
Ensure that a similar path is present in the presented variables:
C:\Users\[Username]\AppData\Local\Programs\Python\PythonXXX\Scripts
The username and the “XXX” are dependent upon your user account name and the installed Python version.
You can also view the environment variables from the Settings app, and through PowerShell.
If you find that such a variable doesn’t exist, then it means that the issue is caused because of a missing pip variable in PATH. However, if one does exist, then it is likely that its value is misconfigured.
Either way, continue to perform the following mitigation tasks to correct the error and get on with your Python development.
Fix PIP Not Recognized in Windows
Add Environment Variable for PIP
This section covers 2 ways to add the environment variable for PIP. Of course, you only need to perform this if the Python directory did not show up in the list of environment variables when you checked for them using the Command Prompt above.
Add PIP Environment Variable using System Properties
This method shows how to add the PIP environment variable to PATH using Windows GUI.
-
Open the System Properties applet by typing in “sysdm.cpl” in the Run Command box.
-
Switch to the Advanced tab.
-
Click “Environment Variables.”
-
Under the System Variables section, select “Path,” and then click Edit.
-
From the popup window, click New.
-
Now enter the path for the PythonXXX directory, as in the following image:
Note: You can use File Explorer to navigate to the Python directory and copy the correct path from there.
-
Now click New again and enter a second path for the Scripts directory.
-
Click Ok on all windows to save the changes.
The environment variables will now be added to PATH.
Add PIP Environment Variable using Command Prompt
You can also add the PIP environment variable using the Command Prompt in just a few commands. Here is how:
-
Launch an elevated Command Prompt.
-
Use the following cmdlet while changing the [Username] and [XXX] with your account name and Python version to add the PIP environment variable to PATH:
setx PATH “%PATH%; C:\Users\[Username]\AppData\Local\Programs\Python\PythonXXX
Edit Environment Variable for Python
If the Python directory did show up when you were checking the variables list, and the PIP command still isn’t working, then it is probably misconfigured.
Use the following steps to edit the existing PATH variable:
-
Open the System Properties applet by typing in “sysdm.cpl” in the Run Command box.
-
Switch to the Advanced tab.
-
Click “Environment Variables.”
-
Under the System Variables section, select “Path,” and then click Edit.
-
Select the Python entry and click Edit.
-
Repeat the steps above for the other path (if needed).
-
Click Ok on all windows to save the changes.
Ensure PIP is Included in Python Installation
Python has different components installed. Ensure that PIP is one of the installed components using these steps:
-
Open the Programs and Features applet by typing in “appwiz.cpl” in the Run Command box.
-
Right-click Python and then click Modify from the context menu.
The modification wizard will now launch.
-
Click Modify.
-
Make sure that “pip” is selected, then click Next.
-
Now ensure that “Add Python to environment variables” is selected, and then click Install.
Any newly selected packages and variables will now install.
-
When the installation completes, close the wizard.
If this resolution did not work for you, you can try and reinstall Python all together.
Reinstall Python with PATH Variable
Another workaround for the error prompt is to reinstall Python on your PC. When installing Python, it gives you the option to place the environment variables into PATH.
Follow these steps to uninstall Python and then reinstall it properly.
-
Open the Programs and Features applet by typing in “appwiz.cpl” in the Run Command box.
-
Right-click Python and then click Uninstall.
The uninstallation wizard will now run and remove Python from your PC.
-
Close the wizard and restart the computer.
-
Now download the Python setup and run it.
-
From the installation wizard, select “Add pythno.exe to PATH” and then click “Install Now.”
The installation will now begin.
-
When installed, close the wizard.
A fresh environment variable path has now been added to the system. Check to see if your issue has been resolved and that PIP is recognized now.
Install Python Package without PIP Variable
If none of these solutions have worked for you, then another workaround is to install a Python package without adding the PIP variable. It can be done using a simple cmdlet in Command Prompt.
-
Launch an elevated Command Prompt.
-
Use the following cmdlet to install a Python package while replacing [PackageName] with the name of the package:
python -m pip install [PackageName]
As you can see in the image above, the Django package has been installed without adding the pip variable in PATH.
Final Words
The Pip Installation Packages is a crucial command for managing Python libraries and packages. Therefore, you need to ensure that it is working correctly on your PC in order to maximize productivity.
Let us know which method from above worked for you in resolving the issue.