Last modified: Oct 01, 2026

How to List Installed Python Packages

Python projects depend on many packages. Over time, your environment can fill up with libraries you no longer remember installing.

Knowing how to list installed Python packages helps you debug errors, share requirements, and keep your environment clean.

This guide shows you every practical way to see your installed packages. It covers pip commands, Python code, and virtual environments.

Why Listing Installed Packages Matters

Every Python environment has its own set of packages. A package installed in one project may be missing in another.

Listing packages helps you in several ways:

You can check if a library is already installed before adding it again. You can create a requirements file for others. You can also spot outdated or conflicting versions.

This is important for beginners. Many errors come from missing or mismatched packages.

Method 1: Using pip list

The pip list command is the most common way to list packages. It shows every package in your current environment.

Open your terminal or command prompt. Then run this command:


pip list

The output shows two columns: package name and version.


Package    Version
---------- -------
numpy      1.26.4
pandas     2.2.1
pip        24.0
requests   2.31.0

This list is easy to read. It is great for a quick check.

If you use Python 3 and pip points to Python 2, try pip3 list instead.

Method 2: Using pip freeze

The pip freeze command lists packages in a requirements format. Each line shows a package and its exact version.


pip freeze

Here is a sample output:


numpy==1.26.4
pandas==2.2.1
requests==2.31.0

This format is perfect for sharing. You can save it to a file like this:


pip freeze > requirements.txt

Others can then install the same packages with pip install -r requirements.txt.

Note that pip freeze only shows packages installed with pip. It may skip some system tools.

Method 3: Using pip show for Details

Sometimes you need details about one package. The pip show command gives you that.


pip show requests

The output includes the version, location, and dependencies.


Name: requests
Version: 2.31.0
Summary: Python HTTP for Humans.
Location: /usr/lib/python3/site-packages
Requires: certifi, charset-normalizer, idna, urllib3

This is useful when you want to know where a package lives or what it needs.

Method 4: Listing Packages with Python Code

You can also list packages from inside Python. This works well in scripts and notebooks.

Use the pkg_resources module to get all installed distributions.


# Import the module that tracks installed packages
import pkg_resources

# Loop through every installed distribution
for dist in pkg_resources.working_set:
    # Print the package name and its version
    print(dist.project_name, dist.version)

The output looks like this:


numpy 1.26.4
pandas 2.2.1
requests 2.31.0

This method is handy when you want to filter or sort packages in code.

You can also use importlib.metadata in newer Python versions.


# Import the metadata module for Python 3.8 and above
from importlib.metadata import distributions

# Loop through all installed distributions
for dist in distributions():
    # Print the package name and version
    print(dist.metadata["Name"], dist.version)

Both approaches give you a full list without leaving Python.

Method 5: Checking a Single Package

You may only want to check one package. You can do that in a few ways.

First, try importing it in a Python shell.


# Try to import the package
import numpy

# Print the version if the import works
print(numpy.__version__)

If the import fails, the package is not installed. If it works, you also get the version.

You can also run this command in your terminal:


pip show numpy

This is faster when you just need one answer.

Working with Virtual Environments

A virtual environment is an isolated Python setup. Each one has its own packages.

You must activate the environment before listing packages. Otherwise, you see the global list.


# Create a virtual environment
python -m venv myenv

# Activate it on macOS or Linux
source myenv/bin/activate

# Activate it on Windows
myenv\Scripts\activate

After activation, run pip list again. You will see only the packages in that environment.

This keeps projects separate. It also avoids version conflicts.

Common Problems and Fixes

Sometimes pip is not found. This usually means Python is not on your PATH.

Try python -m pip list instead. This calls pip through Python directly.


python -m pip list

On some systems, you may need python3 -m pip list.

Another issue is seeing the wrong list. This happens when you have several Python versions installed.

Always check which Python you are using. Run which python on macOS or Linux. Run where python on Windows.

This tells you the exact interpreter behind your pip command.

Tips for Clean Environments

Keep your package list tidy. Remove packages you no longer use.

Use pip uninstall package_name to remove one. This keeps your environment small and fast.

Update packages with pip install --upgrade package_name. Outdated packages can cause bugs.

Always record your packages in a requirements file. This makes your project easy to rebuild.

For more details, check the official PyPI website.

Quick Comparison of Methods

Here is a short summary to help you choose.

pip list gives a clean table. pip freeze gives a requirements format. pip show gives details for one package.

Python code gives you full control. It is best for scripts and automation.

Use pip list for a quick look. Use pip freeze when you need to share.

Conclusion

Listing installed Python packages is a basic but powerful skill. It helps you manage projects and fix errors fast.

Start with pip list for a simple overview. Use pip freeze to create requirements files. Use pip show for details on one package.

For more control, list packages with Python code. Always check your virtual environment first.

With these methods, you can keep your Python setup clean, clear, and ready for any project.