Facebooktwitterredditpinterestlinkedintumblr

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,” this blog post is for you. We will discuss how to fix your issue so that you can install 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, your system can’t find pip. Depending on your operating system, 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, pip, and pip3 aren’t installed on your system or 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

Setting up the PIP environment variable differs depending on your installed operating system. 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 been here to set your shell if you need pip, so navigate 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, pip isn’t installed on your computer.

Method 3: Install Python

Python may be missing from your system. Depending on your installed operating system, you can install Python by running the command below.

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:

  • At the Windows search bar, type cmd.
  • When the Command Prompt window appears, click Run as administrator.
  • At the Command Prompt window, download the get-pip.py file by running the following command:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

To install PIP, type:

python get-pip.py

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

pip install --upgrade pip

Once pip has been installed, you can verify it works by listing all the installed packages.

pip list

Conclusion

Have you tried the outlined steps 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 you can get back to coding as soon as possible.

Tim Miller

Tim has always been obsessed with computers his whole life. After working for 25 years in the computer and electronics field, he now enjoys writing about computers to help others. Most of his time is spent in front of his computer or other technology to continue to learn more. He likes to try new things and keep up with the latest industry trends so he can share them with others.

Leave a Comment