‘pip’ is not recognized as an internal or external command, is an error that occurs on the screen when the pip command is used in Windows. This error can be frustrating for Python developers, especially for those who are new to the Windows cmd interface.
There are different reasons behind the encounterment of this specified pip command error in Windows. This post will explain all the possible approaches for fixing the mentioned error in Windows.
What is the “‘pip’ is not recognized as an internal or external command” Error?
This error can be encountered while using the pip command in the Windows cmd. For instance, check the version of the installed “pip” package in Windows cmd:
> pip --version
The error has been displayed on the screen and the possible reasons with their solutions are discussed below in detail.
Possible Reasons Behind the “‘pip’ is not recognized as an internal or external command” Error
The possible reasons behind this encounter error are:
- Python Package not Installed
- Incorrect Path Variable
- Virtual Environment is not Activated
- Restricted Administrative Privileges
All these mentioned reasons are explained with their solutions.
Reason 1: Python Package not Installed
The pip package is dependent on Python, therefore, it is important to ensure that Python has already been installed on the computer. To check the installation of the Python, display the installed version details with the command:
> python --version
The Python package has not been installed on the computer.
Solution: Install the Python Package
To install the Python package on Windows, follow the steps mentioned below.
Step 1: Download the Python Installer
To install the Python, download the Python from the mentioned link:
Step 2: Launch the Python Installer
When the download is completed, run the Python launcher. Click on the “Customize installation” and also ensure the mentioned check boxes are marked:
Step 3: Install the Additional Features
Click on the additional features to install with the Python and then click on the “Next” button:
Step 4: Choose the Installation Folder and Install
Specify the path of the folder to install the Python and then click on the “Install” button:
The installation of Python has been begun:
When the Python package has been installed, a welcome note will be displayed on the screen:
Now display the version of installed Python on Windows cmd:
> python --version
Now again check the version of the pip command:
> pip --version
The error has been resolved with the installation of the Python package on Windows.
Reason 2: Installation of Python has not been added to Path Variable
Another reason for this encounter error of the Pip command is that the installation is not added in the Path variable.
Solution: Add the Installation to the Path Variable
There are two different methods of adding Python to the Path variable. First is to click the check box for the addition to Python to the Path variable during the installation:
If Python has been already installed, then follow the below-mentioned steps to add Python to the Path variable.
Step 1: Open the Settings
Click on the Windows button, and search for the “Settings” as shown:
Step 2: Open the Environmental Variables
Click on the “System” when the Settings are opened on the screen:
Then click on the “About” after scrolling down the left side menu options:
Choose the “Advanced system settings” from the right side menu options:
Finally, click on the “Environmental Variables” option:
Step 3: Make Changes to the Path Variable in Windows
Choose the “Path” variable and then click on the Edit button:
Step 4: Add the Python Path to the Environmental Variables
Finally, add the path of the Python by clicking on the “New” button and then close the window after saving the changes:
The error will be resolved and the pip command can be used.
Reason 3: Virtual Environment is not Activated
Python developers use virtual environments for Python projects. The pip command can be used inside the environment variables. Sometimes using the pip command inside the virtual environment can generate the mentioned error. This is because the virtual environment has not been activated.
Solution: Activate the Virtual Environment
To activate the virtual environment on the Windows cmd to resolve the mentioned error, follow the below-mentioned syntax:
Reason 4: Restricted Administrative Privileges
Some users of the system are not allowed to run administrative commands or tasks and this may encounter the “‘pip’ is not recognized as an internal or external command” error while using the pip command. To resolve this, the pip command must be used as the administrator.
Solution: Run the pip Command as Administrator
To run the pip command as the administrator, follow the below-mentioned steps.
Step 1: Open the Power User Menu
With the help of the “Window+X” shortcut key, the Power User Menu can be accessed:
Step 2: Choose the Windows PowerShell (Admin)
Now from the displayed menu, choose the “Windows PowerShell (Admin)” option:
Step 3: Access the Administrator Windows PowerShell
Finally, run the pip command in the administrator PowerShell as shown below:
These are the 4 common reasons behind the mentioned pip error in Windows.
To fix the “‘pip’ is not recognized as an internal or external command”, make sure that the Python has been installed and its installation is added in the Path variable. Other than this, also make sure that the user is allowed to run the administrative commands, else use the “Windows PowerShell (Admin)” to run the pip command. Similarly, if the pip command is running inside the virtual environment, then make sure that the virtual environment has already been activated. All these four reasons behind this error with their solutions have been explained with the step-by-step guide in this article.