pip is an acronym used for “Pip Installs Packages” or alternatively “Pip Installs Python”, sometimes it is also referred to as “Preferred Installer Program”. pip is a terminal which is generally used to download python packages that can be called in our python projects to achieve the objective of our projects.
But there are certain cases where we encounter an error while using the pip command and get a message as: ‘pip: command not found’. In this article, we are going to discuss the potential reasons behind it and how to solve those problems.
Pip packages can also be installed via py –m pip install packagename command.
If the python command doesn’t get recognized try python –m pip install packagename
Windows version of python uses py command instead of python
Try this before reading further 🙂
Case 1: When pip is installed but still the error persists
In this case, pip is already installed but the error persists because the path variable goes missing. While installing the pip library there may occur a case when pip gets installed in a directory that is not listed in the $PATH environment variable.
Lets first find out if python is installed on your computer by entering the following command on your machine:
For Windows Users:
In my case, it’s showing 3.7.3. Python version 3.4 or later ships with pip by default. If you’re using a version greater than 3.4 then, pip is already installed on your computer. To verify this execute this command
py -m pip -V
It should show your something like this
This means you already got pip installed 🙂 You can use this command to install any package you want. I am installing numpy as an example :
py -m pip install numpy
We have successfully installed NumPy library. If it doesn’t work for you that means you don’t have pip installed. You can follow our second method to install pip.
Since Python 3.4 pip comes installed by default the recommend method for accessing it is “py -m pip”
But if you want to access pip packages using “pip install” and python via the “python” command then you just need to add it to the environmental variable. To add it
- Type “python” in the windows search bar
2. Right-click on your mouse and click on open file location
3. Right-click on your mouse again and go to properties
4.select all text on “start in” option and copy it.
5. In the search bar, type “Environment variable” and open it.
6. Go to the advance tab, and select Environment Variables
7. Under the system variable, scroll down until your find the variable Path and click on edit
8. Click new and paste the directory that you had copied before
9. Click new and paste it again but this time add Scripts\ at the end of it.
10. Press OK and you’re done.
Now restart your computer.
After restarting your computer, open cmd and execute this command
🙂 It will output the current pip version.
Let’s try python
Type this on cmd and press enter
It’s outputting our current python version. We have successfully added environment variable to our system 🙂
For Linux Users:
check if python is installed
It will show you the corresponding version.
Let’s verify if pip is installed
python -m pip -V
If you see something like the above pip is not installed on your Linux system. Please follow our second method for installing it on linux system.
Case 2: When pip library is not installed
Generally, if an individual is using a Python IDE having Python 2 >=2.7.9 or Python 3 >=3.4 version after downloading it from python.org, pip comes already installed and does not need any manual installment. However, if pip is not installed automatically then there are several ways using which we can install pip library in our system based on our system configurations.
Windows User: Execute the following in cmd
py -3 -m ensurepip
If that doesn’t work, then you have to modify or reinstall the package and if it’s showing requirement already satisfied that means you already have it installed.
Search for control panel in the search bar
Click “Uninstall a program ”
Select python then press right-click on your mouse
make sure pip is selected then press next
Make sure “Add python to environment variable” is selected.
Go to the control panel and click uninstall a program
Now go to python’s official website from here
In my case I’m gonna download Python 3.8.7.
Press download, it will take you to the download page. Scroll down to the bottom of the page, you’ll find the download links, download 34/64 bit version according to your need.
Once the download has been finished, open the installer. Make sure that “add python to path” is selected, then press install.
You’ll get a message like this. We just have to disable path length limit and we are done.
Close the installer and restart your computer.
🙂 It should solve the issue. To verify open the terminal and type
py -m pip -VIt will show you the pip version you are using. If it still show you the error you just have to add it to the environment variable by following our step 1 guide. For Linux Users:
sudo apt-get install python-pip
sudo yum install epel-release
sudo yum install python-pip
However, a much easier way to install pip is by following the below-given steps:
- sudo easy_install pip (to be run on the terminal)
User will be asked to set a password as per his/her choice.
- We can then type the command pip –V to check the pip version and verify whether pip got installed or not.
- However, at a later stage if a user wants to upgrade the pip version then he/she can use the command: pip install –U pip