Why does my pip install not work?

This is part of a series discussing everything required to get an all-encompassing grasp of the Python programming language in as short a time as possible. Whether you are a beginner or an expert, I intend for you to learn something new.

PIP is a powerful tool that everyone should know how to use. But everyone has also at some point been in the position where Python’s PIP has given them trouble and they have been lost as to how to proceed. I have picked up a number of methods of troubleshooting PIP that have been very successful for me.

How to use PIP

Installing modules to python is painfully easy. Simply open up your terminal:

  • Windows — Command Prompt (CMD)
  • MacOS — Terminal
  • Linux — Terminal (it depends…)

Now in your command line, type:

pip install (THE NAME OF THE MODULE)

Sometimes, in MacOS and Linux, you may need to instead type:

sudo pip install (THE NAME OF THE MODULE)

(This will not work in Windows no matter how hard you try.)

Now if none of that works, that means you have a problem. So let’s try and fix that.

Troubleshooting PIP

Basic Stuff

When you are frustrated it is sometimes easy to forget to double check things. First make sure that you have installed Python. Assuming that, the first thing to do is to check if the module exists. The main way to do this is to go to PyPi and search for your package. If nothing comes up, make sure to do a quick google search to see if you are searching by the correct name. StackOverflow is your friend.

If you do find the module you need simply copy the command from the page and paste it into your terminal and away you may go.

If this still does not work, try one last thing before you continue onto the rest of the steps. Try typing:

pip3 install (THE NAME OF THE MODULE)

This may work if you have multiple versions of python installed, one of them being Python3.

One special case you may find yourself in is that the python module used to exist and, for whatever reason, no longer is part of PIP. In this case there is but one solution I have found. This is to try and find a .whl or wheel package for the python module. I will be covering installing those kinds of files later in the article.

Trying to fix PIP

You can try upgrading pip with:

python -m pip install --upgrade pip

or you could just try and install pip from scratch by doing the following.

Copy the code from get-pip.py or save the file from the link. Then simply run the file with python. This should install pip for you and get it working. Make sure to try using pip3 if needed.

Conclusive solution

If all else fails, this has been a reliable way to get pip working on your python install. I would like to preface this with the fact that this shouldn’t be used consistently and I personally recommend simply reinstalling python after uninstalling all the current installations. The solution is to simply attempt one of the following commands:

python -m pip install (THE NAME OF THE MODULE) 
python3 -m pip install (THE NAME OF THE MODULE)

This runs pip through python shell and is almost guaranteed to work. If this still does not work you should definitely uninstall all traces of Python before reinstalling Python3 from the Python website.

Installing wheel packages

You can install wheel packages using one of the following commands:

pip install (THE PATH TO THE WHL FILE) 
pip3 install (THE PATH TO THE WHL FILE)
python -m pip install (THE PATH TO THE WHL FILE)
python3 -m pip install (THE PATH TO THE WHL FILE)

Some users trying to install Python packages using a Command Prompt window report seeing the “pip is not recognized as an internal or external command” error. Most affected users report that the issue occurs even after installing the Python distribution and making sure that Python is added to the path variable. The issue is not specific to a certain OS since it’s reported on Windows 7, Windows 8 and Windows 10.

Why does my pip install not work?
‘pip’ is not recognized as an internal or external command, operable program or batch file

What is PIP?

PiP is a recursive acronym for “Pip Installs Packages“. It’s essentially a package management system used to install and manage software packages written in Python. Most users make use of PiP to install and manage Python packages found in the Python Package Index.

The latest Python versions (Python 2.7.9 and later and Python 3.4) include Pip by default.

What is causing the ‘pip’ is not recognized as an internal or external command error?

We investigated this issue by looking at various user reports and trying to replicate the issue on our computers. From what we gathered, there are several scenarios that are known to trigger this particular error message:

  • PIP installation is not added to the system variable – In order to be able to run Python commands from a CMD window, you will need to add the path of your PiP installation to your PATH in the system variable. If you installed Python using the installation executable, it should be added automatically.
  • The installation is incorrectly added in your PATH – It’s easy to mess up the PATH if you add it manually. Additional space or the missing of a semicolon before the new PATH will end up producing the error.

If you’re currently trying to resolve this particular error message that prevents you from using Python command in CMD, follow the methods advertised in this article. All the potential fixes below are confirmed to be working by at least one affected users.

For the best results, follow the methods below in order until you find a fix that helps you to resolve the issue in your particular scenario.

Method 1: Checking if PIP is added to your PATH variable

Let’s start by finding out where we stand. If you don’t know if your PIP installation is added to your PATH variable, you can find it out easily by using a certain command at a CMD prompt.

Knowing this will point you in the right direction and save you from trying out unnecessary steps.

Note: If you already know if the path of your PIP installation is added to your PATH variable, move down to the next methods below.

Here’s a quick guide on checking if the PIP installation is already in your PATH variable:

  1. Press Windows key + R to open up a Run dialog box. Then, type “cmd” and press Enter to open up Command Prompt.
    Why does my pip install not work?
    Run dialog: cmd
  2. Inside the command prompt window, type echo %PATH% and press Enter to get a listing with all locations added to the PATH variable.
    Why does my pip install not work?
    Checking to see if the PIP installation is present in the PATH variable
  3. If you manage to find a path similar to C:\Python37\Scripts (this depends on your Python version), it means that the installation path is already added to your PATH variable. In this case, you can skip next to methods below and jump straight to Method 4 where we start troubleshooting for problems related to the PiP installation path.

If you weren’t able to find the PiP installation path using the test above, move down to the next methods below (Method 2 and Method 3) to add PIP to the PATH environment variable.

Method 2: Adding PIP to the PATH environment variable using the Windows GUI

If Method 1 revealed that the PIP installation is not set to the PATH as an environment variable and you already installed the Python distribution, you’ll need to do it manually.

After completing the procedure below, you will be able to input PiP commands from a Command Prompt window. Here’s a quick guide on Adding the PiP installation to the Path environment variable using the Windows GUI:

  1. Press Windows key + R to open up a Run dialog box. Then, type “sysdm.cpl” and press Enter to open up the System Properties screen.
    Why does my pip install not work?
    Run dialog: sysdm.cpl
  2. Inside the System Properties screen, go to the Advanced tab, then click on Environment Variables.
    Why does my pip install not work?
    Go to the Advanced tab and click on Environment Variables
  3. In the Environment Variables screen, go to System variables and click on Path to select it. Then with the Path selected, click the Edit… button.
    Why does my pip install not work?
    Select the Path entry under System variables and click Edit
  4. In the Edit environment variable screen, click on New and add the path where the PiP installation is located. For Python 3.4, the default location is C:\Python34\Scripts.
    Why does my pip install not work?
    Adding the PiP installation location
  5. Once the path is added, open a fresh CMD window and try to install a python package that comes with PiP. You should no longer see the “pip is not recognized as an internal or external command” error.

If you’re looking for a quicker way to add the PiP location to the environment variable, follow Method 3.

Method 3: Adding PIP to the PATH environment variable using CMD

A quicker way to set up the PIP path environment variable is to do it directly from a CMD window. This will save you some time, but it can be a little more intimidating if you’re not used to using the terminal.

Here’s a quick guide on setting the PiP path environment directly from a Command Prompt window:

  1. Press Windows key + R to open up a Run dialog box. Then, type “cmd” and press Enter to open a Command Prompt window.
    Why does my pip install not work?
    Run dialog: cmd
  2. In the Command Prompt window, run the following command to set the PIP installation to the environment variable:
    setx PATH “%PATH%;C:\Python37\Scripts”

    Note: Keep in mind that in this command, we used the default location for Python 3.7. If you’re using a different Python version or you installed it in a custom location, change the path after ‘;‘ accordingly.

  3. See if this method was successfully by running a Python installation package (one that uses PIP) from the same CMD window. If you’re still encountering the error message, move down to the next method below.

Method 4: Opening the Python package without adding the PiP variable

If you’re looking for a way to install a Python package from CMD without adding PiP to the PATH environment variable, you can use a couple of different commands to install it. This also works if you used the methods above to configure the environment PATH variable but you’re still encountering the error message.

Here’s a couple of ways that you can use to open Python install packages in CMD without adding the PIP variable:

The Short Method:

  1. Press Windows key + R to open up a Run dialog box. Then, type “cmd” and press Enter to open a Command Prompt Window.
    Why does my pip install not work?
    Run dialog: cmd
  2. Type the following commands and make sure to change the placeholder to your own package name:
    python -m pip install [packagename]

    Note: Change [packagename] with the name of the package you’re trying to install.

The Long Method:

  1. Open a Run dialog box by pressing Windows key + R. Then, type “cmd” and hit Enter to open a Command Prompt window.
    Why does my pip install not work?
    Run dialog: cmd
  2. In the CMD window, use the following command to navigate to the directory where the python .whl file is located.
    cd C:\python installs

    Note: In our example, the Python install package was located in a folder called python installs. Adapt this command to navigate to the directory where the wheel is located.

  3. Next, run the following command to install the Python package using PiP:
    c:\python37\scripts\pip.exe install [package].whl

    Note: Keep in mind need to change the location of your python installation if you have an older version or if you installed into a custom location. Also, make sure to change the [package] placeholder to your own package name.

If these two last methods didn’t enable you to install the Python package from the CMD window, follow the last method below where we ensure that PiP is installed.

Method 5: Ensuring that PiP is included in your Python installation

Before we go ahead and reinstall the whole Python environment, let’s see whether PiP was not omitted from the Python installation. Certain Python installers will leave PiP out of the default installation.

Luckily, you can rectify this by modifying the Python installation and modifying it to install PIP. Here’s a quick guide on how to do this:

  1. Press Windows key + R to open up a Run dialog box. Then, type “appwiz.cpl” and press Enter to open Programs and Features.
    Why does my pip install not work?
    Run dialog: appwiz.cpl
  2. Inside Programs and Features, right-click on the Python installation and click Change.
    Why does my pip install not work?
    Change the Python installation
  3. At the Modify Setup screen, click on Modify.
    Why does my pip install not work?
    Click on Modify to ensure that PiP is installed
  4. In the Optional Features screen, check the box associated with pip and click Next.
    Why does my pip install not work?
    Modifying the Python installation to include PiP
  5. Hit the Install button to make the changes to the Python installation.
    Why does my pip install not work?
    Changing the Python installation
  6. Once the Python installation is modified, open a CMD window and see if you’re able to install a Python package with PiP without seeing the “pip is not recognized as an internal or external command” error.

Method 6: Installing Python via the executable installer

If you’ve come this far without a result, reinstalling Python along with its components will likely resolve the “pip is not recognized as an internal or external command” error.

The easiest way to do this is by using the Python executable installer. If you configure it correctly, it will install PiP automatically. Here’s a quick guide on how to do this:

  1. Press Windows key + R to open up a Run dialog box. Then, type “appwiz.cpl” and press Enter to open Programs and Features.
    Why does my pip install not work?
    Run dialog: appwiz.cpl
  2. Inside Programs and Features, scroll down to the programs list to find the Python installation. Once you find it, right-click on it and choose Uninstall, then follow the on-screen prompts to remove it from your system. Once the Python distribution is removed from your computer, restart your machine.
    Why does my pip install not work?
    Uninstalling Python from your machine
  3. At the next startup, visit this link (here) and download the latest Python executable installer according to your Os architecture.
    Why does my pip install not work?
    Downloading the right Python executable installer
  4. Open the installation executable and start by making sure that the box associated with Add Python to PATH is checked – This ensures that you can run Python commands in Command Prompt. Then, click on Customize installation.
    Why does my pip install not work?
    Ensure that Python is added to PATH, then click on Customize installation
  5. In the Optional Features window, make sure that the box associated with pip is checked, then click Next.
    Why does my pip install not work?
    Make sure that pip is checked under optional features
  6. Leave the default location and Advanced Options, then click Install to commence the installation.
    Why does my pip install not work?
    Installing Python
  7. Once the installation is complete, restart your computer manually if you’re not automatically prompted to do so.
  8. At the next startup, see if the issue has been resolved by trying to install a Python package via a CMD window.
  9. If you’re still seeing the “pip is not recognized as an internal or external command” error, type the following command in a CMD window:
    python -m ensurepip --default-pip
    

    Note: With certain Python distributions (particularly 3.6), it’s possible that PiP doesn’t get installed by default. One of the official fixes for this included in the documentation is this command.

Why does my pip install not work?

Kevin is a dynamic and self-motivated information technology professional, with a Thorough knowledge of all facets pertaining to network infrastructure design, implementation and administration. Superior record of delivering simultaneous large-scale mission critical projects on time and under budget.