Last Updated on October 8, 2021 by Jay
‘pip’ is not recognized as an internal or external command, operable program or batch file.
If that looks familiar then you’ve come to the right place. I’m going to show you how to fix it. This is a common issue if you didn’t install Python properly. Note that you are not alone – experienced users can also run into this issue!
Python Installation
You will need a Python IDE (Integrated Development Environment). There are many different ones out there, so feel free to use any one of them. I’m going to use the vanilla Python IDE, and it can be found here: https://www.python.org/downloads/.
I highly recommend getting the 64-bit version of Python.
The 64-bit Python will allow you to use more RAM than the 32-bit version, kind of similar to Excel. Generally speaking, more RAM = more processing power.
If you are not sure, the ones in red box are the 64-bit version of Python. Pick one that suits your operating system.
I’m installing the most recent version as of today (April 16, 2020), which is v3.8.2. Once you open up the installer, here’s what you’ll see.
You can just click on “Install Now”, which will install Python with all the default settings. But I like to install Python to a different folder, so I’ll go with Customize installation, feel free to skip this step if you like.
Make sure you check the “Add Python 3.8 to PATH” box, this will save you a lot of trouble down the road. However, if you missed it, that’s also fine, and we can fix that later. I intentionally omitted the checkbox on this step.
Click on Install, and wait for it to complete.
Setup was successful – YAY! Well, you wish it was that simple. Now, your Python will work, but the setup isn’t complete, you’ll get an error when trying to install libraries. Let’s take a look at that next.
Library installation/setup
The easiest way to install 3rd party Python libraries is to use pip install
, which should be already available to you from the standard Python installation.
Bring up a Command Prompt. Now if you are using a company laptop, chances are there are other user profiles on your laptop. So you want to run the Command Prompt as administer. This way you’ll have more flexibility with the pip install
.
I’m going to install our favorite library – pandas
. To do that, I just need to type pip install pandas
in the Command Prompt, and then press enter.
So why is it telling me that “pip is not recognized” when I just installed it???
This is because we missed the “Add Python to PATH” checkbox during the Python installation stage. pip is a program written in Python, the computer doesn’t know yet where to find this pip program. So we have to tell the computer where to look.
Add PATH
Go to your Python installation folder. For me, it’s C:\Program Files\Python38
. Your Python folder might be different if you used the default installation setup. The pip
program is stored in C:\Program Files\Python38\Scripts
Copy the current folder location. Next, go to your Windows search bar, type “PATH”, the following window will pop up. Open it, and click on the “Edit the system environment variables”.
Then click on “Environment Variables”.
Under User variables, select “PATH”, then “Edit”. Then click on “New” to add a new environment variable.
Here we are going to add two new variables. One is Your Python installation folder, the other one is the folder that contains the pip program. In my case:
Hit “Ok” a couple of times to save the changes. Now, you need to restart the Command Prompt to make sure the new environment variables get picked up. Now let’s re-run the command pip install pandas
.
It worked!
Library folder
But where did pandas
get installed to? Go to your Python installation folder. Again, it’s C:\Program Files\Python38
for me. Then, go to Lib -> site-packages
. You can find pandas
here. In fact, the site-packages folder is the home for all the 3rd party libraries. This folder is likely to grow as you use Python more.
Let’s review…
- First of all, make sure you check Add Python to PATH box during installation.
- If you missed it, manually add the Python folder (and the Script folder) to PATH environment variable.
- And use
pip install
to get any 3rd party Python library.
Now you have Python, enjoy!