Learn how to troubleshoot and resolve the commonly encountered “‘pip’ is not recognized as an internal or external command” error on Windows systems. This guide explains the probable causes and provides step-by-step solutions to fix the issue.
Symptom: 'pip' Not Recognized Error
When attempting to use the pip command in the Command Prompt on a Windows system, you might encounter the following error message:
'pip' is not recognized as an internal or external command, operable program, or batch file.This error indicates that either the Python installation is not properly configured, or the pip command is unavailable.
Cause: Missing or Incorrect Paths
The primary reasons for encountering this error are:
- Incorrect PATH Environment Variable: The directories containing Python and
pipare not referenced in the system's PATH variable. - Pip Not Installed: The
pippackage manager may not be installed on your system.
Fix 1: Add Python to Environment Variables
Improper PATH configuration is often the root cause. Follow these steps to add Python and pip to your PATH environment variables:
prerequisites
- Ensure Python is installed on your system.
- Use a Python installation that includes
pip.
steps
- Open Command Prompt.
- Verify Python is installed and note its location by running:bash
where python - Copy the directory path, excluding
python.exe(e.g.,C:\Python39). - Open the Environment Variables editor:
- Press the Windows key and search for "Environment Variables."
- Click "Edit the system environment variables."
- In the System Properties window, click "Environment Variables."
- Under "System Variables," locate and select the
Pathvariable. Then click Edit. - Add the following entries to the PATH:
- The Python installation directory you copied earlier (e.g.,
C:\Python39). - The
Scriptsfolder in the same directory (e.g.,C:\Python39\Scripts).
- The Python installation directory you copied earlier (e.g.,
- Click OK on all open dialogs to save changes.
- Close and reopen Command Prompt, then run:bashIf the correct version is displayed, the issue is resolved.
pip --version
Fix 2: Install pip Manually
If pip is missing, install it manually using these steps.
prerequisites
- Python 3.x must be installed on your system.
steps
- Download the
get-pip.pyfile:- Visit the official pip website and locate the download link for
get-pip.py. - Save the file to a directory like
Downloads.
- Visit the official pip website and locate the download link for
- Open Command Prompt and navigate to the directory where you saved
get-pip.py:bashcd %USERPROFILE%\Downloads - Install pip by running:bash
python get-pip.py - Add pip to the PATH by following the steps in Fix 1 to include the
Scriptsfolder. - Verify the installation by running:bash
pip --version
Verification
After completing the setup, confirm that pip is accessible.
Verify pip Installation
pip --version
# Example output:
# pip 21.2.4 from C:\Python39\lib\site-packages\pip (python 3.9)If no error appears and the version number is displayed, pip is successfully installed and configured.
Common Pitfalls and Tips
FAQ
What is the cause of the “‘pip’ is not recognized” error?
This error appears when pip is either not installed on your system or not correctly added to the PATH environment variable.
How do I check if pip is installed?
Run pip --version in Command Prompt. If pip is installed, this command will display its version and install location.
How do I fix the issue if environment variables are correct but pip still cannot be found?
Ensure that pip was installed alongside Python. If it is missing, follow the manual installation steps provided in the article.
Should I use global pip installations or virtual environments?
For project-specific dependencies, it’s recommended to use a virtual environment. You can set one up using:
python -m venv myenvThen activate it with myenv\Scripts\activate before using pip.
Official reference: Python documentation.