Find which version of package is installed with pip
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
If you need to know which version of a Python package is installed, the most direct answer is python -m pip show package-name. The important detail is using the same Python interpreter that your project actually runs, because package versions are tied to environments, not just to the machine.
Use pip show for One Package
The standard command is:
Typical output looks like this:
The Version: line is the value most people want, but the Location: line is often just as useful because it tells you which environment the package came from.
Using python -m pip is safer than a bare pip command. It makes sure pip runs under the interpreter you named, which matters if you have multiple Python versions installed.
Use pip list When You Want a Broader View
If you are not sure whether the package is installed at all, or you want to scan the full environment, list packages:
To narrow the output, combine it with a shell filter:
Or use pip list in freeze format:
That form is convenient when you want output that resembles a requirements file.
Use pip freeze for Reproducible Environments
pip freeze prints installed distributions pinned to exact versions:
Example output:
This is useful when generating dependency snapshots, but it is less descriptive than pip show because it only prints package pins.
Make Sure You Are Checking the Right Environment
This is where many developers get tripped up. You may have:
- a system Python
- a virtual environment
- a Conda environment
- an IDE-managed interpreter
These can all hold different versions of the same package.
For example:
Those commands help confirm which interpreter and installer you are actually using.
Inside a virtual environment, the right version is usually:
On Windows, activation is different, but the idea is the same: activate first, then inspect the package from that environment.
Package Name vs Import Name
Another source of confusion is that the package you install is not always the same as the module you import. For instance, you install beautifulsoup4, but import bs4.
If pip show bs4 fails, try the distribution name instead:
When in doubt, check the project’s installation instructions or inspect your environment with pip list.
A Quick Python-Side Check
If you want to confirm the version from inside the running interpreter, use Python itself:
This is not a pip command, but it is very useful when debugging inside a running application or notebook.
Common Pitfalls
The biggest pitfall is checking the wrong interpreter. pip show can be completely accurate and still mislead you if it belongs to a different Python installation than the one your app uses.
Another common mistake is searching with the import name instead of the installed distribution name. Those are often, but not always, the same.
People also confuse pip list and pip freeze. list is better for browsing an environment, while freeze is better for exact dependency pins.
Finally, if a package is editable or installed from a local checkout, version output may not tell the whole story. In that case, also inspect the package location.
Summary
- Use
python -m pip show package-namefor the clearest single-package version check. - Use
python -m pip listwhen you want to browse the whole environment. - Use
python -m pip freezewhen you need pinned versions for reproducibility. - Always verify that you are checking the correct Python interpreter or virtual environment.
- If
pip showfails, confirm whether the install name differs from the import name.

