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

When encountering the error “pip is not recognized as an internal or external command,” it typically occurs when trying to use pip in the command prompt, but the system cannot find the executable.

This error means that the command-line interpreter cannot locate the pip executable within the directories listed in the system’s PATH variable (a list of directories where the system looks for executable files).

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

First step is, 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.

  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.

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.

  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 highlighted, click on Edit….
    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.

2. Install a Python Package Without Adding the pip Variable

If adding pip to the PATH environment variable is not a viable solution, or if 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. Prefacing your pip command with python -m explicitly directs Python to run the pip module as a script.

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.

3. 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.

  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.

4. 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.

  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'</caption]
  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</caption]
  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</caption]
  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.