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 Fix The 'No Module Named Pip' Error
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:
4. After the installation is complete, verify that pip is installed by running the following command:
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: How to Force Pip to Reinstall the Current Version in Python
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.