How To Fix 'Pip' Not Recognized As Internal Or External Command

Avatar

By squashlabs, Last Updated: Sept. 3, 2023

How To Fix 'Pip' Not Recognized As Internal Or External Command

If you encounter the error message "'pip' is not recognized as an internal or external command, operable program or batch file" when trying to use the pip command in Python, it means that the pip executable is not recognized by your operating system. This issue commonly occurs on Windows systems, but it can also occur on other platforms.

There are several reasons why this error may occur:

1. Python is not installed or not added to the system's PATH variable

If Python is not installed on your system or not added to the system's PATH variable, the operating system will not be able to locate the pip executable. To fix this issue, you need to install Python and add it to the system's PATH variable.

To install Python, follow these steps:

1. Go to the Python website (https://www.python.org/) and download the latest version of Python for your operating system.

2. Run the installer and follow the installation instructions.

3. Make sure to check the box "Add Python to PATH" during the installation process.

After installing Python, you need to add it to the system's PATH variable:

1. Open the Control Panel on your computer.

2. Go to "System and Security" and click on "System".

3. Click on "Advanced system settings" on the left-hand side.

4. In the System Properties window, click on the "Environment Variables" button.

5. In the "System variables" section, scroll down and find the "Path" variable. Select it and click on the "Edit" button.

6. In the Edit Environment Variable window, click on the "New" button and add the path to the Python installation directory (e.g., C:\PythonXX\ for Python 3.X, where XX is the version number).

7. Click "OK" to save the changes.

Once you have installed Python and added it to the system's PATH variable, you should be able to use the pip command without encountering the "'pip' is not recognized as an internal or external command" error.

Related Article: How to Use Python's Not Equal Operator

2. Pip is not installed or not added to the system's PATH variable

If Python is installed but pip is not, you will encounter the same error message. To fix this issue, you need to install pip separately.

To install pip, follow these steps:

1. Open a command prompt or terminal.

2. Download the get-pip.py script using the following command:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

3. Run the script using the following command:

python get-pip.py

4. After the installation is complete, verify that pip is installed by running the following command:

pip --version

If pip is installed successfully, you should see the version number.

If pip is already installed but not added to the system's PATH variable, you can add it manually by following the steps mentioned in the previous section.

3. Python or pip installation is corrupted

Sometimes, the Python or pip installation may get corrupted, leading to issues with the pip command. In this case, you need to reinstall Python and pip to fix the problem.

Here are the steps to reinstall Python and pip:

1. Uninstall Python from your system through the Control Panel.

2. Delete the Python installation directory (e.g., C:\PythonXX\).

3. Download the latest version of Python from the official Python website (https://www.python.org/) and reinstall it.

4. During the installation process, make sure to check the box "Add Python to PATH" to add Python to the system's PATH variable.

5. After Python is installed, follow the steps mentioned earlier to install pip.

By reinstalling Python and pip, you can ensure that the installations are clean and free from any corruption.

4. Antivirus or security software is blocking the pip command

In some cases, antivirus or security software installed on your system may block the execution of the pip command. These security tools often flag pip as a potentially harmful program and prevent it from running.

To fix this issue, you can try the following steps:

1. Temporarily disable your antivirus or security software.

2. Run the pip command again to see if it works without any issues.

3. If pip works after disabling the antivirus or security software, you can add an exception or whitelist the pip executable in your security software to prevent it from blocking future pip commands.

If adding an exception or whitelisting the pip executable does not resolve the issue, you may need to consult the documentation or support resources for your specific antivirus or security software to find a solution.

Related Article: Python Typing Module Tutorial: Use Cases and Code Snippets

5. Other potential reasons

There may be other reasons why you are encountering the "'pip' is not recognized as an internal or external command" error. Some additional troubleshooting steps you can try include:

- Checking if the pip executable is present in the correct location. On Windows, the pip executable is typically located in the "Scripts" folder within the Python installation directory.

- Verifying that the Python installation is not corrupted by running other Python commands or scripts.

- Rebooting your computer and trying the pip command again.

- Checking if any recent system updates or changes may have affected the Python or pip installation.

If none of the above steps resolve the issue, it may be helpful to seek assistance from the Python community or forums where experienced users can provide further guidance based on your specific setup.

Remember, it is important to ensure that both Python and pip are properly installed and configured on your system to avoid encountering the "'pip' is not recognized as an internal or external command" error.

More Articles from the Python Tutorial: From Basics to Advanced Concepts series:

How to Convert JSON to CSV in Python

This article provides a guide on how to convert JSON to CSV using Python. Suitable for all levels of expertise, it covers two methods: using the json… read more

Python Sort Dictionary Tutorial

Learn how to easily sort dictionaries in Python with this tutorial. From sorting by key to sorting by value, this guide covers everything you need to… read more

How To Handle Ambiguous Truth Value In Python Series

Learn how to handle ambiguous truth value in Python series using a.empty, a.bool(), a.item(), a.any() or a.all(). This article covers background info… read more

How to Pip Install From a Git Repo Branch

Guide on executing pip install from a specific Git Repo Branch in Python. This article provides step-by-step instructions on how to install packages … read more

How to Use the IsAlpha Function in Python

This article provides a detailed guide on the usage and applications of the isalpha function in Python programming. It covers the overview of the isa… read more

How to End Python Programs

This guide provides software developers with essential information on correctly terminating Python programs. It covers various methods for ending Pyt… read more

Python Reduce Function Explained

An article explaining the Python reduce function and its uses. The article covers the reduce function in functional programming, lambda functions and… read more

Implementing a cURL command in Python

This guide provides a detailed overview of using Curl in Python for data fetching, including an introduction to HTTP requests and using the Python Re… read more

Creating Random Strings with Letters & Digits in Python

Creating random strings with letters and digits in Python is a useful skill for various programming tasks. This guide explores two methods, using the… read more

Python Bitwise Operators Tutorial

Learn how to use Python bitwise operators with this tutorial. From understanding the basic operators like AND, OR, XOR, and NOT, to exploring advance… read more