Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Python Tutorial
  • Interview Questions
  • Python Quiz
  • Python Glossary
  • Python Projects
  • Practice Python
  • Data Science With Python
  • Python Web Dev
  • DSA with Python
  • Python OOPs
Open In App
Next Article:
How to Install Packages in Python on Linux?
Next article icon

How To List Installed Python Packages

Last Updated : 07 Aug, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

Working on Python projects may require you to list the installed Python packages in order to manage dependencies, check for updates, or share project requirements with others. In this post, we'll look at numerous techniques for listing the Python packages that are installed on your system.

List Installed Python Packages

Below are some methods by which we can list installed Python Packages:

  • Using pip list
  • Using pip freeze
  • Using Python's pkg_resources
  • Using pipdeptree
  • Using pipenv
  • Using Jupyter Notebook

List Installed Python Packages using pip list

The most common method for listing installed Python packages is by using the pip command-line tool. pip is the standard package manager for Python, and it comes pre-installed with Python 3.4 and later versions.

We can list installed packages using pip by using the list command. Just open the terminal or command prompt and run the following command and you will see the list of all installed packages.

pip list

This command will display a list of all the Python packages installed in your Python environment and their versions. You can also redirect the output to a text file(Optional) If you want to save the list of installed packages to a text file, you can use the following command:

pip list > installed_packages.txt

This command will create a file named installed_packages.txt and save the list of packages in it.

List Python Packages using pip freeze

Another commonly used command to list installed packages, especially in the context of Python project management, is pip freeze. This command generates a list of installed packages and their versions in a format that is commonly used for specifying project dependencies in a requirements.txt file.

We can use pip freeze to list installed Python packages. Just open your terminal or command prompt and run the following command.

pip freeze

This command will display a list of installed packages and their versions, similar to what you might find in a requirements.txt file.

List Python Packages using Python's pkg_resources Module

If you prefer a programmatic approach to list installed packages from within a Python script, you can use the pkg_resources module from the setuptools package. Here's an example of how to use it:

Python
import pkg_resources  installed_packages = pkg_resources.working_set for package in installed_packages:     print(f"{package.key}=={package.version}") 

This script will print the names and versions of all installed packages in your Python environment.

List Python Packages using pipdeptree

pipdeptree is a Python package that helps you visualize and list the dependencies of installed packages in a tree-like structure. To use it, you need to install it first:

pip install pipdeptree

After installing pipdeptree, you can list installed packages and their dependencies as follows:

pipdeptree

This command will display a tree-like structure of installed packages and their dependencies.

List Installed Packages using pipenv

pipenv is a popular tool for managing Python project environments and dependencies. It combines pip and virtualenv to create isolated Python environments for your projects. To list installed packages within a pipenv environment, follow these steps:

  • Open a terminal or command prompt and navigate to the directory where your Pipfile is located.
  • Activate the virtual environment:
pipenv shell

List installed packages:

pipenv lock --requirements

This command will display the list of installed packages and their versions.

Using Jupyter Notebook

If we are using Jupyter Notebook for Python development and want to list installed packages within a notebook, we can do so using the ! (shell command) prefix. Here's how:

  • Open a Jupyter Notebook: Launch a Jupyter Notebook by running jupyter notebook in your terminal.
  • Create a new notebook or open an existing one: You can create a new notebook or open an existing one where you want to list the installed packages.
  • List installed packages within a notebook cell:
!pip list

Next Article
How to Install Packages in Python on Linux?

P

prakritjvla
Improve
Article Tags :
  • Python
  • Geeks Premier League
  • Geeks Premier League 2023
Practice Tags :
  • python

Similar Reads

  • How to Check If Python Package Is Installed
    In this article, we are going to see how to check if Python package is installed or not. Check If Python Package is InstalledThere are various methods to check if Python is installed or not, here we are discussing some generally used methods for Check If Python Package Is Installed or not which are
    5 min read
  • How to Manually Install Python Packages?
    Python is one of the most famous and powerful languages in the world. It is a dynamically typed, high-level interpreted language intended for general use. Python first made its public appearance in the year 1991, which means it is a fairly old language. It was designed by Guido Van Rossum and develo
    4 min read
  • How to Install Packages in Python on Linux?
    To install a package in python, we use pip. The pip is a python package manager. In this tutorial, we will be discussing how we can install packages in python on a Linux system. To install packages in python on Linux, we must have python and pip installed on our Linux machine. As python comes preins
    2 min read
  • How to Install Packages in Python on MacOS?
    To get started with using pip, you should install Python on your system. Make sure that you have a working pip. Installing Packages in Python on MacOS: Follow the below steps to install python packages on MacOS: Step 1: As the first step, you should check that you have a working Python with pip inst
    2 min read
  • How to Install python-YAML package on Linux?
    PyYAML is a special Python library for the package that is often used for the configuration of files and also can be used for data exchange purposes. PyYAML package is a Python YAML parser that permits the user to write YAML data and also parse it. PyYAML library is quite similar to the JSON library
    2 min read
  • How to Install python3-xlib package on Linux?
    The Python3-xlib Library is intended to be a fully functional X client library for Python programs. It is written entirely in Python language, indifference to earlier X libraries for Python (the ancient X extension and the newer plxlib) which were interfaces to the C Xlib. So, in this article, we wi
    2 min read
  • How to Install Python-web2py package on Linux?
    Web2py is a Python package that helps web developers to create dynamic online content. Although a web developer may construct a form from scratch if necessary, Web2py is meant to assist decrease tiresome web development activities like building web forms from scratch. So, in this article, we'll use
    2 min read
  • How to Install Python-pymarc package on Linux?
    Pymarc is a python package for working with bibliographic data encoded in MARC21. Pymarc provides an API for reading, writing, and revising MARC records. It was mostly designed to be an emergency eject seat, forgetting your data assets out of MARC and into some kind of more rational representation.
    2 min read
  • How to Install Python-pickle package on Linux?
    Python pickle package is used for serializing and de-serializing a Python object structure. Any object in Python can be pickled so that it can be stored on the local disk. What pickle does is that it “serializes” the object first before writing it to a file. Pickling is a way to transform a python o
    2 min read
  • How to Install "Python-PyPDF2" package on Linux?
    PyPDF2 is a Python module for extracting document-specific information, merging PDF files, separating PDF pages, adding watermarks to files, encrypting and decrypting PDF files, and so on. PyPDF2 is a pure python module so it can run on any platform without any platform-related dependencies on any e
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences