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 Different Python Versions With Virtualenv

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: FastAPI Enterprise Basics: SSO, RBAC, and Auditing

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:

Fixing "ValueError: Setting Array with a Sequenc" In Python

When working with arrays in Python, you may encounter the "ValueError: setting an array element with a sequence" error. This article provides solutio… read more

16 Amazing Python Libraries You Can Use Now

In this article, we will introduce you to 16 amazing Python libraries that are widely used by top software teams. These libraries are powerful tools … read more

How to Iterate and Loop Through Python Dictionaries

Learn how to iterate and loop through Python dictionaries. Understand the basics of dictionary iteration and explore different looping techniques. Di… read more

How to Automatically Create a Requirements.txt in Python

Managing dependencies in Python is crucial for smooth software development. In this article, we will explore two methods to automatically create a re… 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 Create Pandas Dataframe From Variables - Valueerror

Constructing a Pandas dataframe from variables in Python can sometimes result in a ValueError, especially when using only scalar values and no index.… read more

How to Work with CSV Files in Python: An Advanced Guide

Processing CSV files in Python has never been easier. In this advanced guide, we will transform the way you work with CSV files. From basic data mani… read more

How To Filter Dataframe Rows Based On Column Values

Learn how to select rows from a dataframe based on their column values using Python's pandas library. Explore two methods, Boolean Indexing and the Q… read more

How To Exit/Deactivate a Python Virtualenv

Learn how to exit a Python virtualenv easily using two simple methods. Discover why you might need to exit a virtual environment and explore alternat… read more

How to Force Pip to Reinstall the Current Version in Python

Guide to using pip for forcing reinstallation of the current Python version. This article provides step-by-step instructions on using the –force-rein… read more