Let’s say you receive an error message from Git Bash.

bash: pip: command not found

What Is a Pip Command Not Found Error?

A “pip: command not found” error occurs when you fail to properly install the package installer for Python (pip) needed to run Python on your computer. To fix it, you will either need to re-install Python and check the box to add Python to your PATH or install pip on your command line.

And an error message from DOS command line.

'pip' is not recognized as an internal or external command,
operable program or batch file.

What do you do? 

 

How to Fix Pip Command Not Found

If you’ve just installed Python, you may want to rerun your Python installer and make sure you check the box “Add Python 3.6 to PATH.”

pip command not found Python installer image
Python for Windows installer page. | Screenshot: Ashley Gelwix

If not, don’t worry. You can add Python and the pip directory to the PATH in a bit. Next, check here for pip3.exe:

C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36\Scripts

Note that you can’t copy and paste that line. You will need to fill in your actual username in that path.

If you do find “pip 3,” you are in luck. It should look something like the image below.

pip command not found pip3 folder screenshot
The pip3.exe folder on Windows. | Screenshot: Ashley Gelwix

If you’re navigating on Windows, you can easily get to the AppData folder by typing the %appdata% macro into the path bar in a Windows File Explorer (formerly Windows Explorer) window.

pip command not found AppData search screenshot
Search %appdata% to get to the appdata folder on Windows. | Screenshot: Ashley Gelwix

If you can’t find the pip3.exe, it might not be installed. So, the first thing you should do is check to see that you did install pip. Run your Windows Python installer again and check the optional features page to ensure you marked the “pip” box. It’s easy to pass over these little things, and you may have missed it the first time through.

pip command not found python installer optional features
Check the install pip checkbox. | Screenshot: Ashley Gelwix

First, check that you’ve got the “pip” checkbox marked.

pip command not found advanced options screenshot
Mark “Add Python to environment variables” in advanced options. | Screenshot: Ashley Gelwix

Add Python to environment variables so that the Scripts folder with pip3.exe in it can be found. Then make sure that you’ve checked the box for adding Python to environment variables.

More on Coding ErrorsHow to Prevent Kubernetes Configuration Errors

 

How to Install Pip on the Command Line

If you don’t want to run your Python installer again, you can just install pip on the command line. 

It is also quite possible that you may have skipped over this warning right after summoning Python from the command line or after installation.

WARNING: The scripts pip.exe, pip3.6.exe and pip3.exe are installed in 'C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36\Scripts' which is not on PATH.
 Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.

It’s easy to miss, and I think developers get into the habit of ignoring warnings like this because code often compiles with thousands of compiler warnings. 

Now, let’s edit your path. Start by searching for “environment” in your Windows search tab.

pip command not found environment variables screenshot
Search “environment” and edit the environment variables. | Screenshot: Ashley Gelwix

Then select, “Edit the system environment variables.”You will see a window like this below.

pip command not found system properties screenshot
In system properties, select environment variables. | Screenshot: Ashley Gelwix

Click the button the green arrow is pointing to labeled “Environment Variables.”

pip command not found environment variables path
Select the Path you want to edit. | Screenshot: Ashley Gelwix

You will then have a choice. You can either edit the user path or the system path. 

I usually edit the system path and have never run into issues. However, I suspect that the safer thing to do, the more “principle-of-least-privilege” thing to do, would be to edit the user path. That way only the user who needs pip access will have it. It’s up to you, but I typically never have more than one user on my machine. However, many workplaces do.

pip command not found edit paths screenshot
Click the Edit button for whichever path you chose

From there, you’ll want to copy the path we discussed earlier.

C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36\Scripts

Make sure you use your actual username in the place of YOUR_USERNAME. Remember, you can’t just copy paste it. While you’re here, it’s also not a bad idea to add Python to your path. So, add this folder, too. It’s just one level up:

C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36\

If you can’t open the path in File Explorer, it’s not a real path.

pip command not found edit environment variable screenshot
Paste in the Path and click OK. | Screenshot: Ashley Gelwix

Once you’ve pasted in the new path to the end of the path system environment variable, you can click OK to close the window. 

Next you need to restart the terminal, and type in “pip” to check your work. If it works, you should see the help output in the terminal. It should look something like the image below.

pip command not found help output in terminal screenshot
Pip help output in terminal. | Screenshot: Ashley Gelwix

If you don’t see it, you should go back to your path environment variable and make sure it is correct. Watch out for spaces in the wrong place, extra characters, etc.

More on PythonPython Tuples vs. Lists: When to Use Tuples Instead of Lists

The example path I gave you is on the C:/ drive. If you installed pip and Python to a different drive, use that one instead.

Alternatively, you could do this in your ~/.bashrc file for Git Bash. Enter, vim ~/.bashrc to open the bashrc file. This is a file that executes every time you open a shell window. You’ll have to re-open your shell to get the changes that you make to the bashrc file.

alias pip='C:\\Users\\YOUR_USERNAME\\AppData\\Local\\Programs\\Python\\Python36\\pip3.exe'

A few other things to note:

  • You MUST use single quotes as double quotes will not work.
  • You MUST escape your \ slashes.
  • You MUST use Windows style slashes (\). Unix style (/) will not work.
  • You MUST escape your spaces in the path. If YOUR_USERNAME has a space you would enter the following: 
    alias pip='C:\\Users\\YOUR\ USERNAME\\AppData\\Local\\Programs\\Python\\Python36\\Scripts\\pip3.exe'

This can be handy if you don’t think you should edit the path. There’s more than one way to crack an egg. Creating an alias will just make pip automatically call that pip3.exe you pointed it to. However, you may need to add the “Scripts” folder to the path in order to find some modules you installed. 

On Windows especially, it seems to nearly always be safe to append to the path. But I always do that little trick to make sure I have an alias around just in case.

Expert Contributors

Built In’s expert contributor network publishes thoughtful, solutions-oriented stories written by innovative tech professionals. It is the tech industry’s definitive destination for sharing compelling, first-person accounts of problem-solving on the road to innovation.

Learn More

Great Companies Need Great People. That's Where We Come In.

Recruit With Us