Pip is an abbreviation for “Pip Installs Packages” or “Pip Installs Python.” Pip is an abbreviation for “preferred installer program.” It is essentially a package manager that enables you to download and install packages. If you attempt to install packages without pip, you will receive the error pip: command not found.
In this article, we will look at the root cause of this error as well as possible solutions to resolve the problem you are currently experiencing.
Fix pip: command not Found
The nature of the problem varies depending on the environment and the operating system that you are using. Let’s take a look at how the pip package is packaged for different environments.
Error Message On Command Prompt:
'pip' is not recognized as an internal or external command, operable program or batch file.
Error Message On Bash or Terminal:
bash: pip: command not found
if you have installed Python in a Linux environment, the pip package manager is not included with the Python installation, and you must install the pip package manager as an additional package. When you try to install packages in Linux, you will receive a pip: command not found error, which indicates that the pip package is not installed on your system.
For Mac users, installing the latest version of Python 3.x eliminates the need to worry about installing it separately from the operating system. It is pre-installed with the Python distributable.
Windows – Once again, you do not need to install the pip package separately on Windows. It is pre-installed with Python distributable.
Because Python 2 has reached its end of life, as you are probably aware, it is no longer being actively maintained and supported by the Python development community. If you are still using Python 2, you should consider upgrading to Python 3, which includes the pip3 package manager.
How To Check If pip Is Installed Properly?
The first and most important thing to do is to determine whether or not pip has already been installed on your computer.
In Windows, you can see if the pip package is located in the directory listed below. Consequently, simply navigate to the directory in question and look for pip.exe or pip3.exe files. If it is not already present, you will need to install it.
Look For Pip3.exe File
C:\Users\YOUR_USERNAME\AppData\Local\Programs\Python\Python36\Scripts where, YOUR_USERNAME = it is your system name.
Uninstall And Install PIP Again To Fix The Issue
If you are using Windows, then follow the steps below to uninstall and then properly install the pip on your system. However, before running the following command, ensure that the command prompt is in administrator mode.
pip uninstall pip
Once the uninstallation is complete, restart your computer to ensure that all temporary files are also removed from your system, ensuring that pip is completely removed from your system. Now run the below command on your command prompt.
py -m ensurepip --upgrade
Or if you do not want to uninstall then you can try upgrading the pip which should also fix any issue with your current pip installation.
py -m pip install --upgrade pip
Using the apt-get command in your terminal, you can install pip3 on your computer.
sudo apt-get -y install python3-pip
As soon as you’ve run this command, you should follow up with the pip3 package manager commands to download the necessary packages.
If you want to upgrade pip if it is already installed on your Linux system, use the following command, which should also resolve the issues you are experiencing.
python -m pip install --upgrade pip
You must re-install Python on a Mac because pip is bundled with the Python distributable, which can be accomplished by running the following command: Once Python 3 has been re-installed, you should be able to run pip commands again without issue.
brew install python3
To upgrade pip on macOS, run the following command, and your pip will be uninstalled and the new version installed immediately.
python -m pip install --upgrade pip
How To Install pip For Python 2?
If you are still working with Python 2 and would like to install an older version of pip, you can do so by running the command below on your Linux machine: pip install oldversion.
sudo easy_install pip
This command adds the pip command to the command line arsenal of your system. If it hasn’t already been done, install easy install with the following Linux command.
sudo apt-get install python-setuptools
I hope the methods discussed above helped you resolve your pip: command not found issue. I’ve included instructions for Windows, Linux, and MacOS. You can select the one that best suits your needs based on your operating system.
The most common issues related to pip if you already have it installed can be fixed using the upgrade command of the pip discussed above.