Table of Contents
Pip (PIP install packages) is a package manager application used to install 3.rd party python packages. The Python packages that come with the operating system may not always be up to date or there may be conflicts when you install them. This is why using pip is important.
During or after installation, users encounter "zsh: command not found: pip". There are 2 possible causes here for this error. Let's examine them.
Cause-1: Pip package not installed
Solution - 1: Install pip package from official repository
Almost all Linux operating systems have
pip packages in their package repositories. So you can use the default package manager based on your environment to install pip.
Now here I am getting below error while trying to execute
[root@almalinux8]/home/foc# pip zsh: pip: command not found... Install package 'python3-pip' to provide command 'pip'? [N/y]
If you think it is not installed on your system, continue with "
y". You must switch to root user for this process. Otherwise, you will have an authorization problem in the installation process. Then it will ask you for information for installation:
[root@almalinux8]/home/foc# pip zsh: pip: command not found... Install package 'python3-pip' to provide command 'pip'? [N/y] y * Waiting in queue... The following packages have to be installed: python3-pip-21.2.3-6.el9.noarch A tool for installing and managing Python3 packages Proceed with changes? [N/y] y * Waiting in queue... * Waiting for authentication... * Waiting in queue... * Downloading packages... * Requesting data... * Testing changes... * Installing packages...
After this process, pip will be installed. Now you can enter
pip and press TAB and it should you the list of installed
[root@almalinux8]/home/foc# pip pip pip-3 pip3 pip-3.9 pip3.9 pipewire pipewire-pulse
Sometimes there may be problems during package installation. Or the installed
pip may be damaged due to package conflicts. In this case, it may be necessary to remove the
pip package from the system and reinstall it:
[root@almalinux8]/home/foc# dnf reinstall python3-pip Last metadata expiration check: 3:13:14 ago on Tue 06 Sep 2022 03:10:59 PM +03. Dependencies resolved. ==================================================================================================================== Package Architecture Version Repository Size ==================================================================================================================== Reinstalling: python3-pip noarch 21.2.3-6.el9 appstream 1.7 M ... Reinstalled: python3-pip-21.2.3-6.el9.noarch Complete!
You now have a clean pip install. (Steps to install on Debian based systems: How to install pip Ubuntu 20.04?)
Solution - 2: Install from the official repository
You can also download the latest available version of pip from their official repository and install it manually using the following commands:
[root@almalinux8]/home/foc# wget https://bootstrap.pypa.io/get-pip.py [root@almalinux8]/home/foc# python get-pip.py
Cause-2: $PATH Environment Variable Check
I am sure you are familiar with PATH variable but just to give you some background, PATH variable contains the list of PATH which will have all the system binaries. It is possible that your PATH variable was manipulated and now it does not contain the location of pip binary. So it is important to check your PATH variable.
Solution - 1: Check $PATH and Update
Check the user's environment variables. List PATH environment variables with the following command:
[root@almalinux8 foc]# echo $PATH /root/.local/bin:/root/bin:/sbin:/bin:/usr/sbin:/usr/bin
While the application path information is inside
[root@almalinux8 foc]# ls /usr/bin/pip* /usr/bin/pip /usr/bin/pip3 /usr/bin/pip3.9 /usr/bin/pipewire-pulse /usr/bin/pip-3 /usr/bin/pip-3.9 /usr/bin/pipewire
So if your PATH variable doesn't contain /usr/bin then you can add the same using following command:
This command will prepend
/usr/bin into the PATH variable. But this change is temporary and will not survive the reboot. To change this permanently, create a new file inside /etc/profile.d by any name but make sure the file has
We will create a file
/etc/profile.d/pip_path.sh with below content:
Save and exit the file. Now next time the Linux server goes for reboot, it will automatically collect
Solution - 2: Define alias for the pip command
Depending on the Python version, pip is called differently. Python3 is called pip3, and python2 is called pip. If you want to use pip3 when you type pip in the terminal, you must enter it as an alias in files such as
/etc/profile. For example:
[foc@almalinux8 ~]$ nano ~/.zshrc
save and exit. Finally:
[foc@almalinux8 ~]$ source ~/.zshrc
Then when you call pip, the desired version will run. If pip is installed in a different directory, you can define an alias and serve pip to the user that way.
The first cause we described above is encountered more often. The operating system may not always offer the updated version. For a problem-free and up-to-date pip, you can download, install and upgrade from the pip official address.
stackoverflow.com - zsh command cannot found pip