Skip to content

How to Fix Linux pip vs pip3 Command Error

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about How to Fix Linux pip vs pip3 Command Error. We cover key concepts, practical examples, and best practices.

You type pip and get command not found, or pip installs packages for Python 2 when you need Python 3 — the wrong pip version is installed or pip is missing entirely.

The Problem

pip: command not found

Or:

pip install requests
# Installs for Python 2, but you use Python 3

Step-by-Step Fix

Step 1: Check which Python version you use

python --version
python3 --version

If python points to Python 2 and python3 to Python 3, use pip3.

Step 2: Install pip for Python 3

sudo apt update
sudo apt install python3-pip

Step 3: Use python3 -m pip instead of pip3

This always uses the correct pip for Python 3:

# WRONG — may use wrong Python version
pip install requests

# RIGHT — always uses current Python's pip
python3 -m pip install requests

Step 4: Install a specific package for Python 3

python3 -m pip install requests

Or use pip3 explicitly:

pip3 install requests

Step 5: Create a virtual environment

# Create venv with Python 3
python3 -m venv myenv

# Activate
source myenv/bin/activate

# Now pip installs into the venv
pip install requests

Step 6: Install pip if missing (without apt)

For older systems:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python3 get-pip.py

Step 7: Fix pip pointing to the wrong Python version

# Check current pip's Python
pip --version

# If it shows Python 2, use pip3 instead
pip3 --version

# Or reinstall pip for Python 3
sudo python3 -m pip install --upgrade --force-reinstall pip

Prevention Tips

  • Always use python3 -m pip instead of bare pip
  • Use virtual environments per project
  • Set python to Python 3 with sudo apt install python-is-python3
  • Check Python version before installing packages
  • Do not install system-wide packages unless necessary

Common Mistakes with pip python3

  1. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  2. Misunderstanding that String is [Char] with poor performance for large text operations
  3. Using foldl instead of foldl' causing stack overflow on large lists

These mistakes appear frequently in real-world LINUX code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### What is the difference between pip, pip3, and python3 -m pip?

pip is the generic command (may point to pip2 or pip3 depending on the system). pip3 explicitly uses Python 3. python3 -m pip runs pip as a module of Python 3, ensuring the correct Python version is always used.

Why does pip install a package but python3 cannot import it?

pip may be installing for Python 2 while you are using Python 3. Check with pip --version and python3 -m pip --version. Always use python3 -m pip install to match the Python version.

How do I uninstall a package installed with the wrong pip?

If you installed with pip (Python 2) but need it for Python 3, uninstall with the same pip: pip uninstall package, then install with python3 -m pip install package. Or just install again for Python 3 — both versions can coexist.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro