How to Fix “pip is not recognized as an internal or external command” Error?

Encountering the error “pip is not recognized as an internal or external command” while trying to install Python packages means that the system cannot find the pip executable in the directories listed in the system’s PATH environment variable. This usually occurs when the path to the Python installation and its Scripts directory is not correctly added to the PATH.

The most common cause of this issue is that the Python installer did not add the pip directory to the PATH variable during installation. Additional causes can include an incorrect installation of Python, or the PATH variable being misconfigured, such as having extra spaces or missing semicolons.

What is PIP?

pip is a recursive acronym for Pip Installs Packages. It functions as a package manager for installing and managing software packages written in Python. Users commonly rely on pip to install and manage packages from the Python Package Index.

Recent Python versions come with the pip tool by default, making the installation and management of packages straightforward.

Our investigation into this issue, based on user reports and personal testing, uncovered several common causes for this error message:

  • PIP installation not added to system variables – Having the path of your pip installation added to your PATH system variable is a prerequisite for running Python commands from a CMD window. The installation should automatically add this if Python is installed using the official executable.
  • Incorrect PATH entry – Manually adding the PATH can result in errors, such as inserting extra spaces or missing a necessary semicolon, which leads to the error message.

If you are currently struggling with this error, preventing the use of Python commands in CMD, the methods detailed below have been verified to work by at least one user.

1. Check if PIP is Added to your PATH Variable

If PIP’s installation path is missing from this list, your system won’t recognize ‘pip’ as a valid command.

By checking if pip’s path has been correctly added to your system’s PATH variable, you can confirm whether command-line operations can detect and execute pip. If they can’t, it’s likely because the PATH doesn’t include the necessary directory, and simply adding it might get things back on track.

Note: If you already know whether the path of your PIP installation is in your PATH variable, skip ahead to the subsequent methods.

  1. Press Windows key + R to open the Run dialog box. Type cmd and press Enter to open Command Prompt.
    Run dialog: cmd
    Run dialog: cmd
  2. In the Command Prompt window, type echo %PATH% and press Enter. This command will display all locations included in the PATH variable.
    Checking the PIP installation in the PATH variable
    Checking the PIP installation in the PATH variable
  3. If you see a path similar to C:\Python**\Scripts (with ** representing your installed Python version), then the installation path is in your PATH variable.

2. Add PIP to the PATH Environment Variable Using the Windows GUI

If PIP is confirmed to be missing from the PATH as an environment variable, and the Python distribution is already installed, you’ll need to add it manually.

By manually inserting the path to pip’s location via the graphical user interface of the Windows system settings, you grant your Command Prompt the ability to acknowledge pip commands no matter your current directory, thus streamlining your Python package management process.

  1. Press Windows key + R to open a Run dialog box. Type sysdm.cpl and press Enter to access the System Properties window.
    Run dialog: sysdm.cpl
    Run dialog: sysdm.cpl
  2. In the System Properties window, navigate to the Advanced tab and click on Environment Variables.
    Access the Advanced tab to find Environment Variables
    Access the Advanced tab to find Environment Variables
  3. In the Environment Variables window, under System variables, locate and select Path. With Path</.DateField> highlighted, click onEdit….
    Select the Path entry under System variables and click Edit
    Select the Path entry under System variables and click Edit
  4. In the Edit Environment Variable window, click New and add the path where the pip installation is located. The default location for Python 3.4, for example, is C:\Python34\Scripts.
    Note: This path may differ based on your Python version or if you have a different version installed.

    Adding the pip installation location
    Adding the pip installation location
  5. After adding the path, open a new CMD window and attempt to install a Python package using pip.

3. Add PIP to the PATH Environment Variable Using CMD

When you add the PIP directory to your system’s PATH variable through Command Prompt, you basically inform your operating system where to look for the pip executable file. This process grants you the convenience of running pip commands from any directory in CMD, bypassing the need for full paths to pip each time. It’s a swift way to make sure that pip is available system-wide and recognized by your command line environment.

By using the setx command in CMD, you can permanently update the PATH environment variable, so it includes the location of your PIP installation. This adjustment ensures that whenever you type pip in the command line, the system knows where to find and execute the pip command.

  1. Press Windows key + R to bring up the Run dialog box. Type cmd and press Enter to open Command Prompt.
    Run dialog: cmd
    Run dialog: cmd
  2. In Command Prompt, execute the following command to add the PIP installation to the environment variable:
    setx PATH %PATH%;C:\Python37\Scripts

    Note: Remember to adjust the path after ‘;‘ based on your Python version or custom installation directory, assuming the default location for Python 3.7.

  3. Test if this method was successful by trying to install a Python package using PIP from the same Command Prompt window.

4. Install a Python Package Without Adding the pip Variable

If adding pip to the PATH environment variable is not a viable solution for you, or you’ve tried the previous methods and are still facing the error, you can install Python packages from CMD using alternative commands.

This approach avoids the need to rely on the PATH variable by using Python itself to call upon the package installer directly. Basically, by prefacing your pip command with python -m, you explicitly direct Python to run the pip module as a script, facilitating the installation of the desired package without the struggle of modifying system variables.

The Short Method:

  1. Press Windows key + R to open a Run dialog box. Type cmd and press Enter to open a Command Prompt window.
    Run dialog: cmd
    Run dialog: cmd
  2. Execute the command below, replacing ‘[packagename]’ with the name of the package you want to install:
    python -m pip install [packagename]

The Long Method:

  1. Press Windows key + R to activate the Run dialog. Type cmd and hit Enter to launch Command Prompt.
    Run dialog: cmd
    Run dialog: cmd
  2. In Command Prompt, use the command below to navigate to the directory where your Python ‘.whl’ file is located:
    cd C:\python installs

    Note: The directory called ‘python installs’ in this example contains the Python installation packages. Modify this command according to the location of your .whl file.

  3. To install the desired Python package using pip, execute this command:
    c:\python37\scripts\pip.exe install [package].whl

    Note: Modify the python installation location based on your Python version or installation path, and replace ‘[package]’ with the actual package name.

If you’re still not able to install Python packages using CMD after these two methods, make  sure pip is included in your Python installation with the next strategy.

5. Make Sure that pip is Included in your Python Installation

During installation, it’s possible that the pip feature was not selected, leading to its absence in the system’s environment. By adjusting your existing Python installation to include pip, you reinstate its functionality, allowing your system to recognize pip commands across the Command Prompt.

This corrective measure helps close the gap between your Python environment and the essential package manager, reviving your ability to manage and install packages smoothly.

  1. Launch a Run dialog box by pressing Windows key + R. Enter appwiz.cpl and press Enter to open Programs and Features.
  2. In Programs and Features, right-click on your Python installation and choose Change.
    Adjust the Python installation
    Adjust the Python installation
  3. In the Modify Setup pop-up window, click Modify.
    Select Modify to check if pip is installed
    Select Modify to check if pip is installed
  4. On the Optional Features screen, make sure the pip option is ticked, then select Next.
    Edit the Python installation to include pip
    Edit the Python installation to include pip
  5. Press the Install button to apply the changes to the Python installation.
    Applying modifications to the Python installation
    Applying modifications to the Python installation
  6. Checking whether pip works properly with your Python installation in a CMD window will reveal if the error has been fixed.

7. Install Python Using the Executable Installer

During installation, checking the Add Python to PATH option is important as it allows for easy access to Python and pip commands directly from the command line, bypassing previous path issues. This approach is a comprehensive reset that removes any previous misconfigurations and sets up a clean working environment.

  1. Open the Run dialog by pressing Windows key + R. Type appwiz.cpl and press Enter to enter Programs and Features.
  2. Find the Python installation in Programs and Features. Right-click it and choose Uninstall. Follow the displayed instructions to uninstall the program, and then restart your computer.
    Uninstalling Python from the system
    Uninstalling Python from the system
  3. After restarting, visit the website at this link (here) to download the latest Python executable installer appropriate for your OS architecture.
  4. Execute the installer, first making sure to check Add Python to PATH to enable Python commands in Command Prompt. Next, select Customize installation.
    Check 'Add Python to PATH' and click 'Customize installation'
    Check ‘Add Python to PATH’ and click ‘Customize installation’
  5. In the next step, verify that pip is checked among the optional features, then click Next.
    Confirm that pip is selected under Optional Features
    Confirm that pip is selected under Optional Features
  6. Keep the default settings and Advanced Options as they are, and proceed with the installation by clicking Install.
    Proceed with the Python installation
    Proceed with the Python installation
  7. If the system doesn’t prompt you to restart, do so manually.
  8. After the system has restarted, try to install a Python package using the CMD window to verify if the issue has been resolved.
  9. If the error continues, open a CMD window and enter the following command:
    python -m ensurepip --default-pip

    Note: In certain cases, particularly with Python version 3.6, pip might not come with the default installation. This command is an official fix recommended in the documentation for such issues.

ABOUT THE AUTHOR

Kevin Arrows


Kevin Arrows is a highly experienced and knowledgeable technology specialist with over a decade of industry experience. He holds a Microsoft Certified Technology Specialist (MCTS) certification and has a deep passion for staying up-to-date on the latest tech developments. Kevin has written extensively on a wide range of tech-related topics, showcasing his expertise and knowledge in areas such as software development, cybersecurity, and cloud computing. His contributions to the tech field have been widely recognized and respected by his peers, and he is highly regarded for his ability to explain complex technical concepts in a clear and concise manner.