[toc]
Many factors could lead to the error: ‘pip’ is not recognized as an internal or external command. Two of the most common ones are Python’s or pip’s incorrect installation and lacking path in the system environment variables.
This tutorial deeply explains the concept of environment variables, system paths, and pip’s way of storing packages to enable you to track the source of the error comfortably.
It then takes you through a step-by-step way to solve the error. Apart from Windows, you will see how to solve related errors in Linux. What is more? Read on to find out.
βWhat Are Environment Variables?
Understanding environment variables is one the most crucial steps to solving pip’s errors.
A computing environment is a platform consisting of the operating system and the processor. On the other hand, a variable is a place for storing a value. The variable can be binary, text, number, filename, or any other data type. It gets its name during creation and can be displayed, updated, and deleted.
The combination of a computing environment and variable is an environment variable, a dynamic value affecting the behavior of a computer process. A computer process is an instance of a program.
# Determine the value of a variable echo %VARIABLE% # in Windows echo $VARIABLE # in Linux # display %VARIABLE% # in Windows env # command for printing all environment variables OR printenv # show a single environment variable in Linux.
Features Of Environment Variables
- They can be created, read, edited, and deleted.
- Each process has its set of environment variables. A newly created process inherits its parent’s same runtime environment.
- Environment variables occur in scripts and the command line.
- Shell scripts and batch files use environment variables to communicate data and processes to child processes or temporarily store data.
- A running process can access the environment variables for configuration reasons.
- A collection of environment variables behave like an associative array, with keys and values in strings.
- Environment variables may differ depending on the operating system.
- Windows stores the default environment variable values in the registry and sets them in the AUTOEXEC.BAT file.
Examples Of Environment Variables
Here are the typical environment variables that interact with pip.
PATH
The path variable lists the directory where your system searches executables. It enables you to view the location of a directory without typing the full path.
In Windows, the path variables are stored in C:\Windows or C:\Windows\System32. In Linux, they originate from the user’s bin or sbin file.
HOME
It shows the default path to the user’s home directory. For instance, HOME//APPDATA stores app settings in Windows. In Linux, the settings are found in HOME/{.App Name}.
In Windows, the misplaced APPDATA lands in the USERPROFILE environment variable, which should instead be used for dialogs to allow a user to choose between folders. LOCALAPPDATA stores local app settings.
TEMP
It stores temporary processes.
Now that you understand how environment variables play a massive in package working, you should find out specific ways to solve pip’s errors.
βSolution 1: Ensure Pip Is Installed Correctly And Up-to-date
Windows
Pip packages are stored in Python’s installation directory. For instance, installing Python in C:\Python\
stores the default library in C:\Python\Lib\
, while the third-party packages reside in C:\Python\Lib\site-packages
.
If you install a specific Python version as a stand-alone, pip packages reside in APPDATA.
C:\Users\<username>\AppData\Roaming\Python\Python<version-subversion>\site-packages\ # the version can be 310 for Python 3.10 or 38 for Python 3.8
If you install a pip package that does not use a specific location, it lands in Scripts.
C:\Python310\Scripts\
Pip gets installed by default when you install most Python 3 versions. You can confirm the installation by checking the pip’s version or help command.
pip -V # OR pip help

You should get pip’s version version, installation folder, and Python version running it.
pip 22.0.4 from C:\Users\<username>\AppData\Local\Programs\Python\Python310\lib\site-packages\pip (python 3.10)
Otherwise, you could get an error,
'pip' is not recognized as an internal or external command
OR
Python is not recognized as an internal or external command, operable program or batch file.
if you try running python.
python
If you run the above commands without seeing Python, pip, or the installed package, you should download Python.
Install pip as a stand-alone package if pip is still unavailable after installing Python. Download get-pip, and run the following command on the command prompt.
python get-pip.py
Lastly, you can upgrade the pip version and check if the error persists.
python -m pip install --upgrade pip
If the problem is still not solved, try adding Python to the system path variable, as explained in solution 2 of this tutorial.
Linux
The usr
is one of the most crucial folders in Linux. It stores information like user binaries, libraries, documentation, and header files. It is where packages that pip manages get installed.
Say we want to install Python 3.10 on Ubuntu 20.04. We can do that by downloading Python from the source or using the deadsnakes custom PPA as follows.
# Update the system, ensuring the required packages are installed. sudo apt update && sudo apt upgrade -y # Install the required dependency needed to add the custom PPAs. sudo apt install software-properties-common -y # Add the deadsnakes PPA to the list of APT package manager sources. sudo add-apt-repository ppa:deadsnakes/ppa # Download Python 3.10 sudo apt install python3.10 # Confirm successful installation python3.10 --version
The next step is to locate pip.
# pip pip --version # OR pip -V pip list -v # pip3 pip3 -V pip list -v
Either way, you may get the following errors.
# pip Command 'pip' not found, but can be installed with: sudo apt install python3-pip # pip3 Command 'pip3' not found, but can be installed with: sudo apt install python3-pip
You get a similar error when you try installing a package.
# pip pip install django Command 'pip' not found, but can be installed with: sudo apt install python3-pip # pip3 pip3 install django Command 'pip3' not found, but can be installed with: sudo apt install python3-pip
Let’s install pip.
sudo apt install python3-pip

βSolution 2: Add The Path Of Pip Installation To The PATH System Variable
You can use the terminal or the GUI.
setx PATH "%PATH%;C:\Python<version-subversion>\Scripts" # For example setx PATH "%PATH%;C:\Python310\Scripts" # for Python 3.10
To use the GUI,
- copy to the full path of the system variable:
C:\<username>\steve\AppData\Local\Programs\Python\Python310\Scripts
- Type Edit the Environment Variables on the search bar.
- On the pop-up window, click on the Advanced tab followed by Environment Variables.

4. You are presented with two boxes. Highlight path on the first box followed by the Edit button below the box.

5. Click on New, paste the script path you had copied earlier, followed by OK on the bottommost part of the screen.

Conclusion
You have learned the leading causes of the error, “‘pip’ is not recognized as an internal or external command,” while installing packages and two typical ways to correct it.
You can check whether your installation was successful and whether the pip is updated and lies in the correct path. Otherwise, you can take the most appropriate step, as explained in this tutorial.
Please stay tuned and subscribe for more interesting discussions.