‘pip’ is not recognized as an internal or external command, operable program, or batch file

If you are working in a python environment, most of you have faced the situation of “pip is not recognized as an internal or external command, operable program, or batch file”. In this article, we …

‘pip' is not recognized

If you are working in a python environment, most of you have faced the situation of “pip is not recognized as an internal or external command, operable program, or batch file”. In this article, we will find the reason and solution and first “what is pip command?” this article.

what is the pip command?

Preferred Installer Program as known as pip is a package manager that helps to install standard libraries, packages, and modules that are not preinstalled inside the python environment.

When and why getting “pip is not recognized”?

“pip is not recognized” occurred when python is installed but the system is not accessing the pip files to run the pip command due to the large path on which pip files are saved.

Here is the step-by-step method of when you face pip’ is not recognized and its solution to add path into the system variables.

Open your command prompt and run any pip command.

Pip list 

Here you will get the issue of “pip is not recognized”

Microsoft Windows [Version 10.0.19043.1237]
(c) Microsoft Corporation. All rights reserved.

C:\Windows\system32>pip list
'pip' is not recognized as an internal or external command,
operable program or batch file.

Run the below command that checks the python script is available or not in the path.

echo %PATH%

You will get the output as below:

C:\WINDOWS\system32>echo %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\aisha\AppData\Local\Programs\Python\Python39\Scripts;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\aisha\OneDrive\Documents\Python Scripts; D:\Anaconda\Scripts\; C:\Users\aisha\AppData\Local\Programs\Python\Python39\Scripts; C:\Program Files\JetBrains\PyCharm Community Edition 2021.2\bin

if you get the “C:\Users\aisha\AppData\Local\Programs\Python\Python39\Scripts” path, it means the python installed path is already added to the environment variable (Your path can be different but Python\Python39\Scripts contains mandatory). Here we are using Python39 that is an installed version in the machine, your python version can be different. 

After getting the path, modify the setup by a run again python exe file that you have downloaded in the system. Or download from the internet and run again.  

You will get below Modify Setup screen if python is already installed in your machine.

‘pip' is not recognized

 After selecting Modify option, check right the pip inside the optional features box. 

‘pip' is not recognized

Check right the “Add Python to environment variable” and install it again.

Now run any pip command in the command prompt.  It will probably execute without error.

Pip is not recognized

Add path directly by using the command prompt.

Check your app data by entering the below command.

start %AppData%

Add direct path by using the command prompt is an easy way to solve this issue. First, run the below command in the command prompt. This will open the app data folder.

start %AppData%

Open the app data folder go to the AppData from the Roaming folder and select Local > Programs > Python > Python39 > Scripts

‘pip' is not recognized

And copy the path C:\Users\aisha\AppData\Local\Programs\Python\Python39\Scripts 

‘pip' is not recognized

And add that copy path into your command prompt “ setx PATH “%PATH%;” after this

setx PATH "%PATH%; C:\Users\aisha\AppData\Local\Programs\Python\Python39\Scripts"

It will add the path successfully direct to the system variables.

‘pip' is not recognized

Note: copy the right path to add in system variable.

3. Add the path into your system directory by Windows GUI.

Another method to solve the “Pip has not recognized” issue is by using windows GUI by adding a path.

Copy the path of the directory as we have done in the second method and add it to the system variable by using the below steps.

Open “View Advanced system settings”

‘pip' is not recognized

Select environment variable.

‘pip' is not recognized

Inside the system variable, select PATH and select edits

‘pip' is not recognized

There is no python\Scripts path added inside the system variable. 

‘pip' is not recognized

To add the python\Scripts, Select “New” and Add the path of python scripts into the system that we have copied from the python folder “C:\Users\aisha\AppData\Local\Programs\Python\Python39\Scripts”

Note: Everyone has a different python directory path.

‘pip' is not recognized

Click ok on all open boxes and now you can run the pip command

Condition 2:

If you don’t have any “C:\Python39\Scripts” file in your path. 

C:\WINDOWS\system32>echo %PATH%
C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Users\aisha\OneDrive\Documents\Python Scripts; C:\Program Files\JetBrains\PyCharm Community Edition 2021.2\bin

Uninstall the previous version or modify the installed version as mentioned in the above method with pip command and add the path to the environment variables. 

Pip command is not working in Jupyter notebook

Pip Commands that support the command prompt are used in the Jupyter notebook with “!” sign. Such as in the below example, we are using the “pip” command to find the list. but it shows an error in the output.

pip list

Output

Note: you may need to restart the kernel to use updated packages.
D:\Annaconda\python.exe: No module named pip

Use “!” before pip in the jupyter notebook to run the pip command correctly.

!pip list

Output

Package    Version
---------- -------
pip        21.2.4
setuptools 57.4.0

Conclusion

In this article, we used a different method to solve the issue of “pip‘ is not recognized as an internal or external command, operable program, or batch file” when we are using a python environment. 

Suggested Read: Remove Brackets from list Python

Leave a Comment