In this guide, we will discuss what causes this error and explore the available techniques we can use to resolve it.
Pip Command Not Found
The command not found error occurs in Linux systems when the system cannot find the command with the specified name.
Therefore, the pip command not found error means that the system cannot find any binary with the name pip.
Let us discuss the potential causes of this error and how we can resolve it.
Cause 1 – PIP Not Installed
One of the causes of the “pip command not found” error is that pip is not installed on the target system.
Since pip is installed as a separate package on most Linux systems, installing the Python interpreter will not have pip.
You can resolve this by installing pip as a separate package with your system’s package manager.
Debian
$ sudo apt-get install python3-pip -y
REHL/Fedora
Arch/Manjaro
The commands above should install pip3 on all the systems. Keep in mind that the pip3 command is not the same as pip.
Cause #2 – Incorrect Pip
Although you may have pip installed, you can still get the command not found error when calling the pip command.
This is because the command to invoke pip will depend on the version of pip installed. For example, for Python3 pip, you will need to use the command:
For Python 2 pip, use the command:
If you are absolutely sure that you need the Python2 pip, you can install it using the commands:
Debian
REHL/Fedora
Manjaro/Arch
You can then verify that the pip command is working.
Alternative Fix
You may have Python 3 and its corresponding pip installed in some cases. However, you want to use pip instead of pip3 to invoke it.
That’s where your shell aliases come to the rescue.
From our error “zsh command not found pip” error, we know that we are working in the ZSH shell.
Hence, to link the alias pip to pip3, we can edit the .zshrc file:
In the file, add the following entry:
The line above links the alias pip to the command pip3.
We can then apply the changes by running the source command:
You can now verify that the pip command is working as:
pip 21.2.4 from /home/debian/anaconda3/lib/python3.9/site-packages/pip (python 3.9)
The command should return the installed pip version.
Termination
The error “zsh command not found” occurs when you run the pip command in the ZSH shell where pip is not installed. Thanks to this tutorial, we know how to resolve this error by installing the correct pip version and linking pip3 to an alias.
Thanks for reading!!