[SOLVED] zsh: command not found: pip [7 Possible Causes]

Omer Cakmak

Tips and Tricks

Navigating the world of programming often brings us face-to-face with cryptic terminal errors that can seem daunting, especially for beginners. One such error, encountered by many Python enthusiasts, reads as "zsh: command not found: pip". This error, as cryptic as it may initially appear, is a common stumbling block and often arises due to a handful of straightforward issues. It's essential not just to fix this problem but also to understand its root causes, ensuring a smoother coding journey ahead. In this guide, we will unpack the "zsh: command not found: pip" error, exploring its common causes and providing clear solutions. Whether you're a seasoned developer looking for a quick fix or a newbie trying to wrap your head around this issue, our comprehensive exploration will shine a light on this zsh conundrum.


How to Check if pip is Installed?

Using the Terminal or Command Prompt:

On Linux/macOS/Windows:

To check for pip (commonly associated with Python 2):

pip --version

If pip is installed, this command will display its version. If not, you might see a message like "command not found" or "pip is not recognized as an internal or external command".

To check for pip3 (commonly associated with Python 3):

pip3 --version

As with the pip command, this will show the installed version of pip3 if it's present.

Using Python:

You can also determine the presence of pip or pip3 from within a Python environment.

For pip (typically Python 2):

    from pip import __version__ as pip_version
    print(f"pip is installed, version: {pip_version}")
except ImportError:
    print("pip is not installed.")

For pip3 (typically Python 3):

    from pip._internal import __version__ as pip3_version
    print(f"pip3 is installed, version: {pip3_version}")
except ImportError:
    print("pip3 is not installed.")


Possible Causes and Solution for "zsh: command not found: pip"

1. pip isn't installed

One of the most straightforward reasons for the "zsh: command not found: pip" error is that pip itself might not be installed on your system. When you attempt to use pip in zsh (or any other shell), it will fail to recognize the command if the tool hasn't been installed.

Solution: To resolve this, you'll need to install pip. Depending on your system and Python version:

# For Debian-based distributions (like Ubuntu):
sudo apt-get update
sudo apt-get install python3-pip

# For Red Hat-based distributions (like Fedora, CentOS):
sudo yum update
sudo yum install python3-pip

# For newer versions of Fedora (22 and above):
sudo dnf update
sudo dnf install python3-pip

# For openSUSE:
sudo zypper refresh
sudo zypper install python3-pip

# For Arch Linux:
sudo pacman -Syu
sudo pacman -S python-pip

# For Alpine Linux:
sudo apk update
sudo apk add py3-pip


2. PATH variable issue

Another common cause of the "zsh: command not found: pip" error is that pip might be installed on your system, but its installation path is not included in the PATH environment variable. The PATH variable determines where the system looks for executable files, so if pip is not in one of those directories, zsh won't be able to find it.

Solution: You can check where pip is installed using:

which pip

or for Python 3:

which pip3

If the command returns a path, ensure that this path is included in your PATH variable. You can add it by placing the following in your .zshrc file (assuming /path/to/pip is the directory containing pip):

export PATH=$PATH:/path/to/pip

After adding, reload your shell or run source ~/.zshrc for the changes to take effect.

But these changes are non-persistent and will not survive a reboot.

Once you know the path to pip, you'll want to add it to your PATH in the .zshrc file, which is the configuration file for zsh.

Open .zshrc in your preferred text editor. For this example, I'll use vim:

vim ~/.zshrc

Add the path: Scroll to the end of the file and add the following line, replacing /path/to/pip-directory with the directory you found in step 1. Remember, you want the directory, not the full path to the pip executable.

export PATH="$PATH:/path/to/pip-directory"

# For Example (assuming pip3 is inside /usr/bin)

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

Save and close the file: If using nano, you can save the changes by pressing CTRL + O, then press Enter, and exit with CTRL + X.

Reload .zshrc: For the changes to take effect immediately in your current terminal session, run:

source ~/.zshrc

Now, the updated PATH will be set every time you start a new zsh session, making the inclusion of pip's directory permanent.


3. Multiple Python installations

The "zsh: command not found: pip" error can also arise if you have multiple versions of Python installed. For instance, you might have both Python 2.x and Python 3.x on your machine. It's possible that pip is installed for one version but not the other, leading to confusion when trying to use it.

Solution: First, determine which Python versions you have:

python --version


python3 --version

Next, check if pip is installed for each version:

pip --version


pip3 --version


4. Using a virtual environment

Virtual environments in Python are isolated environments that allow projects to maintain their own dependencies, separate from global installations. If you activate a virtual environment and encounter the "zsh: command not found: pip" error, it's possible pip hasn't been installed within that environment.

Example: Suppose you set up a virtual environment using venv:

python3 -m venv myproject

After activating it with:

source myproject/bin/activate

If pip isn't installed in this virtual environment, attempting to run pip will result in the "zsh: command not found: pip" error.


When you're inside an activated virtual environment, you can attempt to ensure that pip is installed specifically for that environment:

# First, ensure you're in your virtual environment. You should see the environment name on the left in your terminal prompt.

# Then, using Python, install pip:
python -m ensurepip

When you run python -m ensurepip:

  • If pip is not present, it will install pip.
  • If pip is already installed, it will essentially be a no-op, meaning it won't do anything, but it's harmless to run.

Alternatively you can use the global pip installation by providing the full path:

First, find out where the global pip is located:

which pip # For Python2
which pip3 # For Python3

This will give you a full path, something like /usr/local/bin/pip (this is just an example; your actual path might differ).

Now, even when you're inside a virtual environment, you can use the global pip by referencing its full path:

/usr/local/bin/pip install <package_name>

Replace /usr/local/bin/pip with the actual path you got from the which command and <package_name> with the name of the package you want to install.

However, do note that it's generally not recommended to mix global and virtual environment pip installations. The primary purpose of a virtual environment is to keep project dependencies isolated. Using the global pip might lead to confusion and potentially conflicting package versions. The first method (installing pip within the virtual environment) is the more recommended approach.


5. Incomplete or interrupted installation

Sometimes, if the installation process for pip gets interrupted or encounters an error, it might not install correctly. This can lead to the "zsh: command not found: pip" message when you attempt to use it.

Example: Imagine you're installing pip via a package manager, and during the installation, your computer unexpectedly shuts down. When you restart and try to use pip, you encounter the "zsh: command not found: pip" error.

Solution: The simplest solution would be to reinstall pip to ensure a complete and correct installation.

# For Debian-based distributions (like Ubuntu):
sudo apt-get update
sudo apt-get --reinstall install python3-pip

# For Red Hat-based distributions (like Fedora, CentOS with YUM):
sudo yum update
sudo yum reinstall python3-pip

# For newer versions of Fedora (22 and above, with DNF):
sudo dnf update
sudo dnf reinstall python3-pip

# For openSUSE:
sudo zypper refresh
sudo zypper install --force python3-pip

# For Arch Linux:
sudo pacman -Syu
sudo pacman -S --overwrite '*' python-pip

# For Alpine Linux:
sudo apk update
# Since APK doesn't have a direct reinstall command, you'll need to use add with --force-reinstall
sudo apk add --force-reinstall py3-pip


6. Mismatch between Python and pip versions

Explanation: On rare occasions, having a severely outdated version of pip or mismatched versions of Python and pip can lead to the "zsh: command not found: pip" error.

Example: You might have updated Python to a newer version but are still using an older version of pip that's incompatible with that Python version. When trying to invoke pip, zsh can't recognize it due to the incompatibility.

Solution: Regularly updating both Python and pip can prevent such issues. You can update pip using:

pip install --upgrade pip


7. Shell cache issue

Explanation: Shells like zsh sometimes cache paths and commands to speed up their operations. If this cache becomes outdated, it might lead to the "zsh: command not found: pip" error, even if pip is correctly installed and set in the PATH.

Example: After successfully installing pip, you still encounter the "zsh: command not found: pip" error. This could be because zsh hasn't refreshed its internal cache and still believes pip doesn't exist.

Solution: You can refresh zsh's cache using the rehash command:


After this, zsh should recognize pip without any issues.



When trying to use pip or pip3 in a terminal, the error "zsh: command not found: pip" can be encountered for several reasons. Addressing these reasons ensures smooth Python package management.

Possible Causes and Solutions:

  1. Pip Isn't Installed:
    • Cause: The obvious reason; pip isn't installed.
    • Solution: Install pip based on your Linux distribution.
  2. PATH Variable Issue:
    • Cause: Pip is installed, but its path isn't added to the PATH environment variable.
    • Solution: Locate the pip installation and add it to the PATH variable. Ensure this change is made in profile scripts for persistence.
  3. Multiple Python Installations:
    • Cause: Different versions of Python can have different pip installations or none at all.
    • Solution: Use version-specific pip commands, like pip2 or pip3.
  4. Using a Virtual Environment:
    • Cause: A Python virtual environment might not have pip installed.
    • Solution: Within the virtual environment, ensure pip's presence or use the global pip by referencing its full path.
  5. Incomplete or Interrupted Installation:
    • Cause: A prior installation process for pip wasn't successful.
    • Solution: Reinstall pip for a complete and correct installation.
  6. Mismatch Between Python and Pip Versions:
    • Cause: Outdated or mismatched pip version.
    • Solution: Update pip to a version compatible with your Python installation.
  7. Shell Cache Issue:
    • Cause: Outdated shell caches might not recognize newly installed commands.
    • Solution: Refresh the shell's cache using commands like rehash.


Further Reading

For more detailed information, including advanced usage and troubleshooting, you can consult the official pip documentation:


Views: 221

Omer Cakmak

He is highly skilled at managing Debian, Ubuntu, CentOS, Oracle Linux, and Red Hat servers. Proficient in bash scripting, Ansible, and AWX central server management, he handles server operations on OpenStack, KVM, Proxmox, and VMware. You can connect with him on LinkedIn or check his projects on GitHub page.

Can't find what you're searching for? Let us assist you.

Enter your query below, and we'll provide instant results tailored to your needs.

If my articles on GoLinuxCloud has helped you, kindly consider buying me a coffee as a token of appreciation.

Buy GoLinuxCloud a Coffee

For any other feedbacks or questions you can send mail to admin@golinuxcloud.com

Thank You for your support!!

Leave a Comment

GoLinuxCloud Logo

We try to offer easy-to-follow guides and tips on various topics such as Linux, Cloud Computing, Programming Languages, Ethical Hacking and much more.

Programming Languages