Oct 25, 2023 3 min read

How to Fix – bash: pip: command not found

Fix-bash: pip: command-not found with our step-by-step tutorial. Pip simplifies Python package installation and management.

Fix – bash: pip: command not found
Table of Contents

Introduction

Before we start talking about how to fix-bash: pip: command not found, let's briefly understand - What is pip?

Pip is a Python package manager that makes it simple to install and manage Python packages. You can see the error message "pip: command not found" when using pip in the Bash terminal. Encountering the error message bash: pip: command not found indicates that the pip package manager for Python is not installed or not accessible in your system's PATH.

This tutorial will provide steps to help you fix the error and use pip successfully. We will also address a few FAQs on how to fix-bash: pip: command not found.

What causes the “pip: command not found” Error?

When the pip command is not installed on your system or when the system cannot find the pip package management, the error "pip: command not found" appears. The following are some potential causes:

  • Pip not installed: The pip command won't be recognized by the terminal if pip isn't installed on your system.
  • Path not set: The system won't be able to locate the pip command if the path is incorrectly configured in the Bash terminal.
  • Incorrect pip version: If you have more than one version of Python installed on your system, it's possible that you installed pip for a version of Python other than the one you're now using.

How to resolve the "pip: command not found" Error?

To resolve the "pip: command not found" problem, follow these steps:

Step 1: Check if pip is installed

To check if pip is installed on your computer, enter the following command into the terminal:

pip --version

This command will show the version number of pip if pip is installed; else, an error message will appear.

The following command can be used to install pip if it is not already installed:

sudo apt-get install python3-pip -y

If you are using a different version of Python, replace "python" with the version you are using in the following command to install pip on your system:

Step 2: Set the path to pip

Run the following command to set the path to pip in the Bash terminal if pip is installed, but the system cannot find the pip command.

export PATH=$PATH:/usr/local/bin

If you installed pip in a different location, replace "/usr/local/bin" with the location of the pip command on your system. In the Bash terminal, this command sets the path to pip.

FAQs to fix-bash: pip: command-not found

Why am I seeing bash: pip: command not found? 

This error occurs because either pip is not installed on your system or the system's PATH variable does not include the location where pip is installed.

How do I check if I have pip installed? 

Open a terminal and type pip --version. If pip is installed, it will display the version number; otherwise, it will display an error message.

How do I install pip on Linux? 

On most Linux distributions, you can install pip by running sudo apt install python-pip for Ubuntu/Debian-based systems, or sudo dnf install python3-pip for Fedora systems.

Why is pip not recognized after installing it on Linux? 

The issue might be that pip was not added to the system's PATH variable during installation. You can try restarting your terminal session or manually adding pip to your PATH.

How do I add pip to the PATH? 

To add pip to your PATH, you need to edit your shell's configuration file, such as .bashrc or .bash_profile, and add the appropriate export statement. For example, export PATH=$PATH:~/.local/bin.

How can I install pip using Python's package manager, pipx?

If you have Python's package manager, pipx, installed, you can run pipx install pip to install pip.

Can I use pip to install packages for both Python 2 and Python 3? 

Yes, if you have both Python 2 and Python 3 installed, you can use pip for Python 2 and pip3 for Python 3.

Conclusion

It is simple to fix the "pip: command not found" error by confirming that pip is installed, adding it if necessary, adjusting the path to pip in Bash, and confirming the pip version. You can simply manage and install Python packages using pip in the Bash shell by following these simple guidelines.

If you have any queries or doubts, please leave them in the comment below. We'll be happy to address them.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to DevOps Tutorials - VegaStack.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.