Skip to main content

A package to list all the installed Python packages and their dependencies

Project description

list_packages

example workflow

A utility to retrieve a list of installed Python packages and their dependencies.

Link to the documentation.

Installation

Install via Terminal:

  1. Clone or download the repository from GitHub to your local computer.

  2. Open a terminal or command prompt and navigate to the root directory of the downloaded repository.

  3. (Optional) It is recommended to create a virtual environment to isolate the package dependencies. Run the following command to create a virtual environment (assuming you have venv installed):

cd list_packages
python3 -m venv env
pip3 install -e .

Install via Pip:

pip install git+https://github.com/maurya-anand/py-list-packages.git

Usage

Terminal

After installing the package, you can run the list-packages command in the terminal to list all installed Python packages and their dependencies:

list_packages

Python Script/Notebook

To use list-packages in a Python notebook, you can import the list_packages module and call the list_installed_packages() function:

## import
from list_packages import list_installed_packages

Examples

Terminal

list_packages

Output

Package                 Dependency
setuptools==59.6.0      None
Jinja2==3.1.2           markupsafe>=2.0
requests==2.31.0        charset-normalizer<4,>=2,certifi>=2017.4.17,urllib3<3,>=1.21.1,idna<4,>=2.5

Python script/Notebook

By default, the function returns a list of dictionaries containing package information. Each dictionary has the following keys:

  • package: Package name (str)
  • version: Package version (str)
  • depends: List of dictionaries containing package information (list)
from list_packages import list_installed_packages

installed_packages = list_installed_packages()

Output

[{'setuptools': '59.6.0', 'depends': None},{'package': 'Jinja2', 'version': '3.1.2', 'depends': [{'package': 'markupsafe', 'version': '>=2.0'}]}]

If you want the output in JSON format, you can pass the format='json' parameter to the list_installed_packages() function. It will return a JSON-formatted string representing the list of installed packages.

from list_packages import list_installed_packages

installed_packages = list_installed_packages('json')

Output

[
  {
    "package": "setuptools",
    "version": "59.6.0",
    "depends": null
  },
  {
    "package": "Jinja2",
    "version": "3.1.2",
    "depends": [
      {
        "package": "markupsafe",
        "version": ">=2.0"
      }
    ]
  }
]

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

list_packages-1.0.3.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

list_packages-1.0.3-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file list_packages-1.0.3.tar.gz.

File metadata

  • Download URL: list_packages-1.0.3.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for list_packages-1.0.3.tar.gz
Algorithm Hash digest
SHA256 7c6afe94c4c2fbf2591babb44fd9a5a6911837863f5366b0af4264e0aa5538b7
MD5 46a323794cc37ae548aface6e84e4dcf
BLAKE2b-256 800c669111e553958aa98329599f48b3445919563cd58885c2b71cbee2525d47

See more details on using hashes here.

File details

Details for the file list_packages-1.0.3-py3-none-any.whl.

File metadata

File hashes

Hashes for list_packages-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 f85e810144be49d1e6c067e605d31c437a38049f35f18f45bc8e646be0a14898
MD5 fcfa2361a90d42c1133bdb49f04e6148
BLAKE2b-256 d4653bbdd6a883357f2f30934c89069937e0265ceb32b3d9b2a72a655195c244

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page