Skip to content
Home
Fix pip: command not found Error on Any OS

Fix pip: command not found Error on Any OS

Python Python 9 min read 1797 words Intermediate ExcellentWiki Editorial Team

The pip: command not found error is one of the first obstacles new Python developers encounter. It means your operating system cannot locate the pip executable in any of the directories listed in your PATH environment variable. This guide covers every cause and solution across Linux, macOS, and Windows, plus best practices to prevent the error from recurring.

Understanding the Root Cause

The error message pip: command not found (or 'pip' is not recognized as an internal or external command on Windows) occurs when the shell searches for the pip binary in all directories listed in the PATH environment variable and does not find it. There are three fundamental reasons this happens: pip is not installed at all, pip is installed but the directory containing it is not in PATH, or you are using a Python installation that does not include pip (such as Python 2 from a system package manager).

Modern Python installations from python.org and most package managers install pip alongside Python. However, many Linux distributions separate the Python runtime from the package installer — you get Python 3 but not python3-pip by default. On macOS, the system Python (deprecated since macOS 12.3) does not include pip. On Windows, the pip installation is optional during the installer wizard.

According to the Python Packaging Authority (PyPA), the recommended way to install pip is through the ensurepip module, which is included with Python 3.4+. This makes python3 -m pip the most reliable invocation method.

Initial Diagnosis

The first diagnostic step is to determine which Python version you have and whether pip is available as a module. Run python3 --version to verify Python is installed. Then try python3 -m pip --version — if this works, pip is installed and the issue is PATH configuration. If it fails, pip needs to be installed.

You can also check which pip3 (Linux/macOS) or where pip3 (Windows) to see if pip exists under its versioned name. Many systems install pip as pip3 by default to avoid conflicts with Python 2’s pip.

Understanding the distinction between pip and pip3 is important. On systems with both Python 2 and Python 3 installed, pip may point to Python 2’s package manager. pip3 unambiguously targets Python 3. On modern systems with only Python 3, both names point to the same executable.

Linux Fixes

On Debian-based distributions (Ubuntu, Debian, Linux Mint, Pop!_OS), pip must be installed as a separate package:

sudo apt update && sudo apt install python3-pip

This installs pip for Python 3. The command pip3 will be available immediately. You may also want a pip command that defaults to Python 3:

sudo ln -s /usr/bin/pip3 /usr/bin/pip

For Fedora, RHEL, and CentOS, use the dnf package manager:

sudo dnf install python3-pip

Arch Linux installs pip as part of the python package, so sudo pacman -S python should include pip. If pip is missing, install python-pip separately.

After installing, verify with pip3 --version. If you see a version number, pip is ready. If pip3 works but pip does not, the symlink above resolves the issue. Alternatively, create an alias in your shell configuration:

echo 'alias pip="pip3"' >> ~/.bashrc
source ~/.bashrc

Some Linux distributions install Python packages to ~/.local/bin for user-level installs (pip install --user). If you installed pip via get-pip.py without sudo, ensure ~/.local/bin is in your PATH:

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

This is also necessary when using pip install --user to install command-line tools, as the executables are placed in the user-local binary directory.

macOS Fixes

macOS presents a unique situation because multiple Python installations can coexist. The system Python (pre-installed with macOS) does not include pip by default and has been deprecated since macOS 12.3.

If you installed Python via Homebrew:

brew install python

Homebrew installs Python 3 and pip together, creating symlinks in /opt/homebrew/bin (Apple Silicon) or /usr/local/bin (Intel). These directories should be in your PATH automatically. Run pip3 --version to verify.

If you downloaded Python from python.org, the installer includes pip but may not add it to PATH. The recommended approach is to use python3 -m pip instead:

python3 -m pip install requests

This always works because it runs pip as a module of the Python interpreter you know is installed. To add pip to PATH permanently, find the Scripts directory:

ls /Library/Frameworks/Python.framework/Versions/3.*/bin

Then add it to your shell profile:

echo 'export PATH="/Library/Frameworks/Python.framework/Versions/3.12/bin:$PATH"' >> ~/.zshrc

If you use pyenv to manage Python versions, pip is included with each Python version you install via pyenv install 3.12.3. Ensure pyenv is initialized in your shell by adding eval "$(pyenv init -)" to your .zshrc or .bash_profile. The Real Python guide on pyenv explains this setup in detail.

Windows Fixes

On Windows, the error appears as 'pip' is not recognized as an internal or external command. The fix depends on whether pip is installed but not in PATH, or not installed at all.

First, check if pip is installed by running:

python -m pip --version

If this returns a version, pip is installed. Add the Scripts folder to PATH:

  1. Press Win + X and select “System”
  2. Click “Advanced system settings”
  3. Click “Environment Variables”
  4. Under “System variables”, find and select “Path”, then click “Edit”
  5. Click “New” and add the Scripts path: C:\Users\YourName\AppData\Local\Programs\Python\Python312\Scripts
  6. Replace “YourName” with your username and “Python312” with your Python version
  7. Click OK on all dialogs and restart your terminal

The Scripts directory location varies by Python version. For Python 3.11 it would be Python311\Scripts, for Python 3.13 it would be Python313\Scripts, and so on.

If python -m pip fails, pip needs to be installed. Run the Python installer again and select “Modify” — ensure “pip” is checked under optional features. Alternatively, download get-pip.py and run:

python get-pip.py

The recommended approach is to use the Python Launcher (py) which is included with Windows Python installations:

py -m pip install requests

The py launcher automatically selects the appropriate Python version and works regardless of PATH configuration. This is documented in PEP 397 and is the most Windows-idiomatic approach.

Using python -m pip

The most reliable way to run pip is through the Python module system:

python3 -m pip install package_name

The -m flag tells Python to run a module as a script. Since you have Python installed (and can verify with python3 --version), this approach bypasses PATH entirely. The pip module is part of the standard library’s ensurepip package and is included with all modern Python installations.

This is the recommended approach in Python’s official documentation for several reasons. It guarantees you are using the pip version associated with the Python interpreter you invoked, avoiding confusion when multiple Python versions are installed. It also works consistently across Linux, macOS, and Windows.

For day-to-day use, many developers create an alias:

alias pip='python3 -m pip'

Add this to your .bashrc or .zshrc for a convenient pip command that never produces “command not found.” You can also use this approach in CI/CD pipelines to ensure the correct Python environment’s pip is always used.

Virtual Environments

Virtual environments contain their own pip installation, eliminating PATH issues entirely. When you create and activate a virtual environment, pip commands work because the environment’s bin/Scripts directory is added to PATH automatically.

python3 -m venv myenv
source myenv/bin/activate  # Linux/macOS
# myenv\Scripts\activate   # Windows
pip install requests       # Works!

Using virtual environments is the recommended practice for all Python projects. They isolate dependencies and prevent conflicts between projects. The pip inside the virtual environment is always available because the activation script modifies PATH. The Python venv documentation details how this works under the hood.

Tools like Poetry and Pipenv automate virtual environment management. Poetry, in particular, has become the standard for new Python projects, providing dependency resolution, virtual environment management, and package building in a single tool. When you run poetry install, it creates a virtual environment automatically and installs dependencies with its bundled pip.

Prevention Tips

To prevent the “pip: command not found” error in the future, adopt these practices:

Always check the “Add Python to PATH” checkbox during Windows installation. This single checkbox prevents the most common cause of the error on Windows. During installation, the checkbox is easy to miss — it appears at the bottom of the first installer screen below the “Install Now” and “Customize installation” options.

Use a version manager for Python. pyenv (Linux/macOS) and pyenv-win (Windows) manage multiple Python versions and ensure pip is installed correctly for each version. They also handle PATH configuration automatically. When you install a new Python version with pyenv, pip and the necessary scripts are set up without manual intervention.

Always use virtual environments for project work. The python3 -m venv venv command creates a virtual environment in the current directory, and source venv/bin/activate activates it with pip ready to use. This pattern is project-scoped and avoids relying on system-wide pip configuration.

Keep your Python installation updated. Outdated Python versions may have pip compatibility issues. The official Python releases at python.org include the latest stable pip version. Update pip itself with python3 -m pip install --upgrade pip. As of 2026, pip 25.x is the current stable line, with regular releases following the pip release process.

FAQ

Why does pip not work but python3 works?

Pip is a separate package from Python on many Linux distributions. Python is installed but the python3-pip package is not. On macOS and Windows, pip may be installed but not in PATH. Running python3 -m pip --version tells you definitively whether pip is installed as a module.

What is the difference between pip and pip3?

On systems with both Python 2 and Python 3 installed, pip points to Python 2’s pip and pip3 points to Python 3’s pip. On modern systems with only Python 3, pip and pip3 are usually the same. Use pip3 explicitly to avoid ambiguity.

How do I fix “pip: command not found” without sudo?

Use python3 -m pip which runs pip as a Python module and does not require root. For user-level package installation, use python3 -m pip install --user package_name. This installs packages to your user directory without affecting the system Python installation.

Does reinstalling Python fix the pip issue?

Reinstalling Python with pip included and PATH configured resolves most issues. On Windows, run the installer again and select “Modify” to add pip. On macOS, use the official installer or Homebrew. On Linux, reinstall the python3-pip package rather than Python itself.

Why does pip work in one terminal but not another?

Different terminals may load different shell configuration files. Ensure your shell profile (.bashrc, .zshrc) contains the pip directory in PATH. New terminals after PATH changes will pick up the updated configuration. Run echo $PATH to compare PATH values across terminals.


Related: Learn about Python virtual environments for isolated project dependency management. Study Python error handling for robust exception handling patterns. Explore Python 3.11 features for the latest language improvements.

Section: Python 1797 words 9 min read Intermediate 756 articles in section Report inaccuracy Back to top