pip or pip3 to install packages for Python 3?
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
If you want to install packages for Python 3, the most reliable answer is usually not "use pip" or "use pip3" in the abstract. The safest command is to invoke pip through the exact Python interpreter you mean, such as python3 -m pip install package-name or, on Windows, py -3 -m pip install package-name.
Why pip and pip3 Can Be Confusing
On some systems:
- '
pippoints to Python 3' - '
pip3also points to Python 3' - both exist and are equivalent
On others:
- '
pipmay point to Python 2 in older setups' - '
pip3points to Python 3' - shell path configuration changes which one you actually get
That is why people get conflicting advice. The command name alone is not the important part. The interpreter behind it is.
Use python -m pip
The most dependable pattern is:
Or on Windows:
This guarantees that the pip module belonging to that Python interpreter performs the installation.
You can check what interpreter and installer you are using:
That is much safer than guessing which standalone pip executable your shell will resolve.
When pip3 Is Fine
If your environment is clean and you know pip3 maps to the intended Python 3 installation, then this is perfectly acceptable:
The problem is not that pip3 is wrong. The problem is that it is less explicit about which interpreter owns the installation.
Virtual Environments Make the Question Easier
Inside an activated virtual environment, plain pip is usually the correct command because it targets that environment.
Create and activate a virtual environment:
Then install packages:
Now pip is bound to the virtual environment, which is exactly what you want for project isolation.
Verify Where the Package Was Installed
If you are unsure whether the package went to the right interpreter, check it explicitly:
That is often the fastest way to diagnose "I installed it, but import still fails" problems.
Avoid sudo When You Can
Global installs with sudo pip or sudo pip3 can create permission and environment problems. In most development workflows, prefer:
- a virtual environment
- user-level installs when appropriate
- project-managed dependency files
For example:
That is still less ideal than a virtual environment for most projects, but it is safer than spraying packages into a system interpreter unnecessarily.
Common Pitfalls
- Assuming
pipalways means Python 3 is unsafe on older or mixed installations. - Using
pip3is not wrong, but it still leaves room for path confusion if multiple Python 3 interpreters exist. - Installing with one interpreter and running code with another is one of the most common packaging mistakes.
- Using
sudo pipfor normal development can damage system Python environments. - Forgetting to activate the virtual environment before installing often sends packages to the wrong place.
Summary
- For Python 3, the most reliable command is usually
python3 -m pip install package-name. - On Windows,
py -3 -m pipis often the clearest form. - '
pip3is fine when you know exactly what it points to.' - Inside an activated virtual environment, plain
pipis normally correct. - When in doubt, check
python -m pip --versionto see which interpreter owns the installation.

