Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Bash Pip Command Not Found: Fix It Fast

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

If you see bash: pip: command not found, it means your shell can't find the pip executable in your PATH. The fix is to install pip (usually via your system's package manager or Python's ensurepip), then make sure the pip script's directory is on your PATH. On most systems, installing the Python 3 pip package and using pip3 instead of pip solves it immediately.

What You'll Need

  • A terminal or command-line session on Linux, macOS, or Windows Subsystem for Linux (WSL).
  • Administrative rights (sudo) if you're installing system packages.
  • Python 3 installed (most modern systems already have it).
  • An internet connection to download packages if needed.

Step-by-Step

  1. Check whether Python is installed and which version you have. Run python3 --version. If it prints a version (e.g., Python 3.x), Python is present. If not, install Python 3 first using your package manager (e.g., sudo apt install python3 on Debian/Ubuntu).
  2. Try the pip module directly. Run python3 -m pip --version. If this works, pip is installed but the pip command isn't on your PATH. You can either use python3 -m pip for all pip commands, or fix your PATH (see step 5).
  3. Install pip using your system's package manager. On Debian/Ubuntu: sudo apt update && sudo apt install python3-pip. On Fedora: sudo dnf install python3-pip. On macOS with Homebrew: brew install python (this includes pip). On Arch: sudo pacman -S python-pip. On WSL, follow the same steps as the Linux distribution you're using.
  4. If your package manager doesn't provide pip, use ensurepip. Run python3 -m ensurepip --upgrade. This bootstraps pip from Python's standard library. If ensurepip is missing (some minimal installs strip it), install the python3-venv or python3-pip package instead.
  5. Check your PATH. Run echo $PATH to see the directories your shell searches. The pip executable is usually in /usr/bin, /usr/local/bin, or ~/.local/bin. If pip is installed but its directory isn't listed, add it. For example, to add ~/.local/bin permanently, append export PATH="$HOME/.local/bin:$PATH" to your shell profile (~/.bashrc or ~/.bash_profile), then run source ~/.bashrc.
  6. Use pip3 if pip still isn't found. Many systems install the Python 3 pip as pip3 to avoid conflict with Python 2. Try pip3 --version. If that works, use pip3 wherever you'd use pip.
  7. Verify the fix. Run pip --version or pip3 --version. You should see the pip version and the Python version it's tied to. Then try installing a small package, e.g., pip install --user requests, to confirm it works.

Common Mistakes

  • Installing pip for the wrong Python version. If you have both Python 2 and 3, pip might point to Python 2's pip, which may be missing. Always use pip3 or python3 -m pip to target Python 3.
  • Forgetting to reload the shell after editing PATH. Changes to ~/.bashrc only apply to new shells. Run source ~/.bashrc or open a new terminal.
  • Using sudo pip install. This can install packages system-wide and cause permission conflicts. Prefer pip install --user or a virtual environment.
  • Assuming pip is broken when it's just not on PATH. The python3 -m pip check in step 2 quickly tells you whether pip exists.
  • Editing the wrong profile file. Bash reads ~/.bashrc for interactive non-login shells and ~/.bash_profile for login shells. If you're unsure, add the export line to both.

Tips

  • Always prefer python3 -m pip over bare pip in scripts; it guarantees you're using the pip tied to that Python interpreter.
  • Create a virtual environment for each project: python3 -m venv myenv, then source myenv/bin/activate. Inside it, pip works without PATH issues and won't affect system packages.
  • On macOS, if you installed Python via python.org, pip is usually at /Library/Frameworks/Python.framework/Versions/3.x/bin/pip3. Add that directory to PATH if needed.
  • Keep pip updated: python3 -m pip install --upgrade pip.
  • If you use multiple Python versions, tools like pyenv can manage shims so the right pip is always on PATH.

Troubleshooting

If pip still isn't found after installation, work through these checks in order:

  • Confirm pip is actually installed. Run python3 -m pip --version. If this fails with "No module named pip", pip is not installed for that Python. Reinstall it via your package manager or python3 -m ensurepip.
  • Find where pip lives. Run which pip3 or find / -name pip3 2>/dev/null (may require sudo). If it's in a directory not on your PATH, add that directory as described in step 5.
  • Check for shell aliases or functions. Run type pip. If it reports an alias or function, it may be pointing to a non-existent command. Remove or fix the alias in your profile.
  • Permission denied errors. If pip runs but can't install packages, use pip install --user or a virtual environment. Avoid sudo pip unless you fully understand the risks.
  • Corporate proxy or firewall. If pip can't reach the package index, configure pip to use your proxy (see pip's official documentation) or use an internal mirror.
  • Reinstall Python and pip. As a last resort, remove and reinstall Python 3 and its pip package using your system's package manager. This will not delete your project files, but it may reset system-wide Python packages.

Frequently Asked Questions

Why does bash say pip: command not found?

Bash searches the directories listed in your PATH for an executable named pip. If pip isn't installed, or its directory isn't in PATH, you get this error. Installing pip and ensuring its location is on PATH fixes it.

What's the difference between pip and pip3?

pip traditionally referred to Python 2's pip, while pip3 is for Python 3. On systems where Python 2 is absent, pip may not exist. Use pip3 or python3 -m pip to be explicit.

Can I use pip without installing it system-wide?

Yes. Use python3 -m ensurepip --user to install pip into your user directory, or create a virtual environment with python3 -m venv, which includes pip by default.

How do I add pip to PATH permanently?

Add a line like export PATH="$HOME/.local/bin:$PATH" to your ~/.bashrc (or ~/.bash_profile), then reload with source ~/.bashrc. The exact directory depends on where pip is installed; use which pip3 to find it.

Why does pip work with sudo but not without?

sudo uses a different PATH (often including system directories). If pip is only in a system directory not in your user PATH, sudo finds it but your normal shell doesn't. Add that directory to your PATH or use python3 -m pip.

Is it safe to use pip install --user?

Yes, --user installs packages into your home directory, avoiding system-wide changes and permission issues. It's the recommended approach for personal use.