BASH Programming

How to Fix – bash: pip: command not found

Pip is a package manager for Python, which helps to install and manage Python packages easily. While using pip in the Bash terminal, you might encounter an error message that reads “pip: command not found”. This issue can happen for a number of reasons and can be annoying for newcomers, but it can be quickly fixed by adhering to a few straightforward procedures. The causes of this mistake and how to fix it are covered in this article.

Why does the “pip: command not found” Error Occur?

The “pip: command not found” error occurs when the pip command is not installed on your system or when the system cannot locate the pip package manager, and here are some reasons that might be causing it:

  • Pip not installed: If pip is not installed on your system, the terminal will not recognize the pip command.
  • Path not set: If the path to the pip command is not set correctly in the Bash terminal, the system will not be able to locate the pip command.
  • Incorrect pip version: If you have multiple versions of Python installed on your system, you might have installed pip for a different version of Python than the one you are currently using.

How To Correct the “pip: command not found” Error?

To correct the “pip: command not found” error, follow these steps:

Step 1: Check if pip is installed

Run the following command in the terminal to see if pip is set up on your machine:

pip --version

If pip is installed, this command will display the version number of pip and if pip is not installed, you will see an error message:

If pip is not installed, you can install it using the following command:

sudo apt-get install python3-pip -y

This command will install pip on your system and if you are using a different version of Python, replace “python” with the version of Python you are using:

Step 2: Set the path to pip

If pip is installed, but the system cannot locate the pip command, you need to set the path to pip in the Bash terminal, and to do this run the following command:

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

This command sets the path to pip in the Bash terminal and if you have installed pip in a different location, replace “/usr/local/bin” with the path to the pip command on your system:

Conclusion

The “pip: command not found” error can be easily corrected by checking if pip is installed, installing it if necessary, setting the path to pip in the Bash, and checking the pip version. By following these simple steps, you can install and manage Python packages easily using pip in the Bash terminal.

About the author

Aaliyan Javaid

I am an electrical engineer and a technical blogger. My keen interest in embedded systems has led me to write and share my knowledge about them.