If you are using Python and trying to install packages with the pip command, but keep getting an error that says “pip command not found,” then this blog post is for you. We will discuss how to fix your issue so that you can get back to installing those awesome packages.

Method 1: Check if Pip is Installed in Your System

There are various ways to check if pip is installed in your system. The first way is to open a terminal and type this command:

$ pip --version
-bash: pip: command not found

If you get the error message above, it means your system isn’t able to find pip. Depending on the operating system you are running, you may be using pip3 rather than pip.

On Linux and Mac, pip is associated with Python 2, and pip3 is associated with Python 3. On Windows, pip is associated with Python 3.

If you’re on Linux or Mac, run this command:

$ pip3 --version
-bash: pip3: command not found

If you’re getting the same error message, it means pip and pip3 aren’t installed on your system or in your path variable.

The next way is to verify if our path variable has been set up properly. To check this, open a terminal and type:

which pip

The location of the pip tool should be provided. If you do not get a response that contains the exact location of your pip command, then there is an issue with your path variable.

Method 2: Add PIP to the PATH Environment Variable

The way to set up the PIP environment variable differs depending on which operating system you have installed. Follow the section specific to your OS.

Set up the path variable on Debian/Ubuntu:

  • Open a terminal and edit your bash profile:
nano ~/.bash_profile
  • Add the following line to your bash profile:
export PATH=/usr/local/bin:$PATH
  • Press Ctrl + X to exit nano. When prompted, press Y to save the file before you exit.
  • Run the pip commands in Method 1 to see if the error “pip command not found” has been fixed.

Set up the path variable on Mac:

  • Open a terminal and edit your bash profile:
nano ~/.bashrc
  • Add the following line to your bash profile:
export PATH=/usr/local/bin:$PATH
  • Press Ctrl + X to exit nano. When prompted, press Y to save the file before you exit.
  • Run the pip commands in Method 1 to see if the error “pip command not found” has been fixed.

Set up the path variable on Windows:

  • Open up your “Start” menu and search for System settings. In the window that pops up click on “System.”
  • Next, click on “Advanced System Settings” in the window that pops up.
  • Then, select the “Environment Variables” button near the bottom of this new window. You should have already been here to set your shell if you need pip so navigate to where it says “Path”.
  • Click “Edit” to modify the existing path.
  • Click on “New” and then type “C:\Python34\Scripts\” (or wherever Python is installed on your machine) in the value field.
  • Click “OK” and then try to run the pip command above again.

If pip is missing from the path variable, you can specify the exact path to pip by typing:

$ /usr/bin/pip --version
-bash: pip: command not found

If you get the error message above, it means pip isn’t installed on your computer.

Method 3: Install Python

Python may be missing from your system. You can install Python by running the command below depending on which operating system you have installed.

Install PIP on Debian/Ubuntu:

sudo apt install python3-pip

Install PIP on CentOS and RHEL:

sudo yum install epel-release 
sudo yum install python-pip

Install PIP on macOS:

brew install python

If Homebrew isn’t installed on your macOS, follow our guide on installing Homebrew.

Install PIP On Windows:

Download the get-pip.py file:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

To install PIP, type:

sudo python get-pip.py

Once installed, you should upgrade to the latest version by running the command:

sudo pip install --upgrade pip

Once pip has been installed, you can verify if it’s working by listing all the installed packages.

pip list

Conclusion

Have you tried the steps we’ve outlined and still encountered the error command not found pip“? Let us know. We can help identify what might be going wrong with your Python installation so that you can get back to coding as soon as possible.

Leave a Comment