List installed Python packages with pip list/freeze | note.nkmk.me (2024)

With pip, the Python package installer, you can list installed packages using the pip list and pip freeze commands.

pip list can filter and display packages by conditions like latest, outdated versions, and those not required by others.

pip freeze is useful for creating requirements.txt, which is used for bulk installation of packages.

  • How to install Python packages with pip and requirements.txt

Contents

  • Differences between pip list and pip freeze
  • Select the output format: --format
  • List up-to-date packages: -u, --uptodate
  • List outdated packages: -o, --outdated
  • List packages not required by others: --not-required

This article does not cover all options. See the official documentation for more details.

For basic pip usage, such as installing, updating, and uninstalling packages, see the following article.

  • How to use pip (Install, update, uninstall packages)

If you are using Anaconda, you can list installed packages with conda list.

Differences between pip list and pip freeze

Below are examples of the output from pip list and pip freeze in the same environment.

$ pip listPackage Version---------- -------future 0.16.0pip 18.1setuptools 39.2.0six 1.11.0wheel 0.31.1
$ pip freezefuture==0.16.0six==1.11.0

The differences between pip list and pip freeze are the output format and whether package management tools like pip are included or excluded.

While the output format of pip list may vary with the version of pip and its settings, pip freeze consistently uses the <package-name>==<version> format, suitable for requirements.txt. Redirecting the pip freeze output to a file using > enables bulk installation of identical packages in a different environment.

  • How to install Python packages with pip and requirements.txt
$ pip freeze > requirements.txt
$ pip install -r requirements.txt

pip freeze excludes package management tools such as pip, wheel, and setuptools, which are not needed for porting environments via requirements.txt, making it ideal for this purpose.

Adding the --all option to pip freeze outputs packages like pip.

$ pip freeze --allfuture==0.16.0pip==18.1setuptools==39.2.0six==1.11.0wheel==0.31.1

As explained below, pip list can filter packages based on various conditions.

Therefore, you should use pip list and pip freeze as follows:

  • Use pip list to list packages under specific conditions
  • Use pip freeze to create requirements.txt

Select the output format: --format

With pip list, you can select the output format using the --format option.

$ pip list --format <format>

<format> can be columns, freeze, or json. As of pip version 23.1, columns is the default format. The legacy format, available in earlier versions, is no longer supported in recent versions of pip.

$ pip list --format columnsPackage Version---------- -------future 0.16.0pip 18.1setuptools 39.2.0six 1.11.0wheel 0.31.1
$ pip list --format freezefuture==0.16.0pip==18.1setuptools==39.2.0six==1.11.0wheel==0.31.1
$ pip list --format json{"version": "0.16.0", "name": "future"}, {"version": "18.1", "name": "pip"}, {"version": "39.2.0", "name": "setuptools"}, {"version": "1.11.0", "name": "six"}, {"version": "0.31.1", "name": "wheel"}

List up-to-date packages: -u, --uptodate

pip list with the -u or --uptodate option outputs only up-to-date packages.

$ pip list -uPackage Version------- -------future 0.16.0pip 18.1six 1.11.0

List outdated packages: -o, --outdated

pip list with the -o or --outdated option outputs only upgradable packages that are not the latest version.

When the output format is set to columns or json, both the currently installed version and the latest version are displayed.

$ pip list -oPackage Version Latest Type---------- ------- ------ -----setuptools 39.2.0 40.4.3 wheelwheel 0.31.1 0.32.1 wheel
$ pip list -o --format json{"latest_filetype": "wheel", "version": "39.2.0", "name": "setuptools", "latest_version": "40.4.3"}, {"latest_filetype": "wheel", "version": "0.31.1", "name": "wheel", "latest_version": "0.32.1"}

Using freeze with -o or --outdated will result in an error.

% pip list -o --format freezeERROR: List format 'freeze' can not be used with the --outdated option.

List packages not required by others: --not-required

Using pip list with the --not-required option lists only packages that are not dependencies of other installed packages.

$ pip list --not-requiredPackage Version---------- -------future 0.16.0pip 18.1setuptools 39.2.0six 1.11.0wheel 0.31.1

Packages shown with this option are standalone and can be uninstalled without affecting the dependencies of other packages. This feature is particularly helpful for cleaning up an environment cluttered with many installed packages.

It is important to note that this option checks only for package dependencies. Therefore, packages that are used as external commands, including pip itself, will appear in the list.

List installed Python packages with pip list/freeze | note.nkmk.me (2024)

FAQs

How do I list all installed packages in pip? ›

To get a list of installed packages in Python, you can use the pip command-line tool with the list command. This will show all packages installed in the current environment.

What does Python pip freeze do? ›

Pip Freeze is a command used in Python to freeze the current state of a virtual environment. This command creates a list of all the installed packages in the virtual environment, along with their versions. This list can be used later to recreate the same virtual environment on another machine.

How to find out what Python packages are installed? ›

The Pip, Pipenv, Anaconda Navigator, and Conda Package Managers can all be used to generate a simple list of installed Python packages, as well as JSON formatted lists.You can also use the ActiveState Platform's command line interface (CLI), the State Tool to list all installed packages using a simple “state packages” ...

How do I get the list of installed modules in Python? ›

To check all the installed Python modules, we can use the following two commands with the 'pip': Using 'pip freeze' command. Using 'pip list command.

How do I find where pip installs packages? ›

Different pip packages may be installed in different places on the same system. Therefore, the best way to find the location of a package is through pip 's show command.

How to check if pip is installed? ›

How to check if pip is installed on Windows and Mac: In Command Prompt on Windows or Terminal on Mac, type and enter: pip --version . If pip version is shown then it is installed.

Is pip Freeze good practice? ›

pip freeze might seem useful initially, but it can mess up your project for the following reasons: It dumps all the libraries installed in your project including dependencies and sub-dependencies in the requirements. txt file. It still misses out on the libraries that are not installed using pip.

What is the use of freeze in Python? ›

pip freeze : This part of the command uses pip , the Python package manager, to list all the installed packages along with their versions. The freeze command is used to produce a formatted output of the packages that can be easily read and used later.

What is the difference between pip freeze and pipreqs? ›

pipreqs vs pip freeze

Essentially, pip freeze will dump all installed packages in your Python environment, creating unnecessarily long and redundant requirements lists (especially if you don't use venvs). In comparison, pipreqs will parse your project files and derive the direct requirements from imports in your code.

Where do installed Python packages go? ›

Location of installed Python packages through Pip

By default, Python packages installed through pip using the ' --user ' flag will be stored in your home directory depending on the specific version of Python they were installed with. Your home directory location, also equivalent to $HOME, will be noted by a ~.

How do I know where Python modules are installed? ›

For a pure Python module, we can locate its source by module_name. __file__. This will return the location where the module's . py file exists.

How to check pip installed packages version? ›

Method 1: Using pip show

The pip show command is one of the most straightforward ways to check the installed version of a package. It provides detailed information about the package, including the version number, location, and dependencies. Open the terminal or command prompt.

How do I get a list of pip installed packages? ›

With pip, the Python package installer, you can list installed packages using the pip list and pip freeze commands. pip list can filter and display packages by conditions like latest, outdated versions, and those not required by others. pip freeze is useful for creating requirements.

How to check if Python is installed? ›

To check if Python is installed on your Windows machine using the Start Menu, follow these steps: Press the Windows key or click on the Start button to open the Start Menu. Type "python". If Python is installed, it should show up as the best match.

What is the command for all installed packages? ›

Listing installed packages by using imcl commands
  • Open a command-line utility.
  • Open the tools directory.
  • Run the command to list installed packages. You can run the listInstalledPackages command with either the -long or the -verbose option, but not both.

What option to the pip command will view all packages that are installed? ›

The pip list command shows all the packages installed in the active environment, in addition to the version numbers of those packages.

How do I update all installed packages in pip? ›

The easiest way to update all packages in a Windows environment is to use pip in conjunction with Windows PowerShell:
  1. Open a command shell by typing 'powershell' in the Search Box of the Task bar.
  2. Enter: pip freeze | %{$_.split('==')[0]} | %{pip install --upgrade $_}
Jan 31, 2020

How do I download all pip packages in Python? ›

Ensure you can run pip from the command line
  1. Securely Download get-pip.py [1]
  2. Run python get-pip.py . [2] This will install or upgrade pip. Additionally, it will install Setuptools and wheel if they're not installed already. Warning.

Top Articles
Expressing Obligation
Personal Security 101: What is RFID Blocking?
Pollen Count Centreville Va
Pangphip Application
Ghosted Imdb Parents Guide
Algebra Calculator Mathway
DEA closing 2 offices in China even as the agency struggles to stem flow of fentanyl chemicals
Practical Magic 123Movies
Ashlyn Peaks Bio
Www Thechristhospital Billpay
My.doculivery.com/Crowncork
Day Octopus | Hawaii Marine Life
Tight Tiny Teen Scouts 5
Bestellung Ahrefs
Truck Toppers For Sale Craigslist
ᐅ Bosch Aero Twin A 863 S Scheibenwischer
Vanessa West Tripod Jeffrey Dahmer
Gino Jennings Live Stream Today
Ou Class Nav
The Ultimate Style Guide To Casual Dress Code For Women
Morristown Daily Record Obituary
Kamzz Llc
Allentown Craigslist Heavy Equipment
Yisd Home Access Center
Bethel Eportal
Teekay Vop
eugene bicycles - craigslist
Finding Safety Data Sheets
Belledelphine Telegram
Evil Dead Rise Showtimes Near Sierra Vista Cinemas 16
Lilpeachbutt69 Stephanie Chavez
10 Best Quotes From Venom (2018)
Dairy Queen Lobby Hours
Kempsville Recreation Center Pool Schedule
Calculator Souo
Word Trip Level 359
Wasmo Link Telegram
2024 Coachella Predictions
Bimmerpost version for Porsche forum?
Go Smiles Herndon Reviews
Karen Wilson Facebook
Shoecarnival Com Careers
Coffee County Tag Office Douglas Ga
Searsport Maine Tide Chart
15 Best Places to Visit in the Northeast During Summer
Mit diesen geheimen Codes verständigen sich Crew-Mitglieder
A Snowy Day In Oakland Showtimes Near Maya Pittsburg Cinemas
Wrentham Outlets Hours Sunday
Ingersoll Greenwood Funeral Home Obituaries
Famous Dave's BBQ Catering, BBQ Catering Packages, Handcrafted Catering, Famous Dave's | Famous Dave's BBQ Restaurant
Latest Posts
Article information

Author: Errol Quitzon

Last Updated:

Views: 6171

Rating: 4.9 / 5 (59 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Errol Quitzon

Birthday: 1993-04-02

Address: 70604 Haley Lane, Port Weldonside, TN 99233-0942

Phone: +9665282866296

Job: Product Retail Agent

Hobby: Computer programming, Horseback riding, Hooping, Dance, Ice skating, Backpacking, Rafting

Introduction: My name is Errol Quitzon, I am a fair, cute, fancy, clean, attractive, sparkling, kind person who loves writing and wants to share my knowledge and understanding with you.