list_packages
A utility to retrieve a list of installed Python packages and their dependencies.
Installation
pip install list-packages
Alternative:
pip install git+https://github.com/maurya-anand/py-list-packages.git
Example 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
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
The output can also be obtained in json format by using the following command in the terminal
list_packages json
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.
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"
}
]
}
]
Links
Metadata
Release files for list-packages 1.0.8
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| list_packages-1.0.8.tar.gz | 3.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| list_packages-1.0.8-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.4 kB
Release files / list_packages-1.0.8.tar.gz
| Download URL | list_packages-1.0.8.tar.gz |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
adf180bf47c3c0311ec367dcfe6916b10ed48a1e50674baf1cac98655d0b189f
|
|
BLAKE2b-256 checksum How to use checksums |
05270edce259e7678570f8092e0ad7d37614e681977cca154c574395cdcfdf03
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Release files / list_packages-1.0.8-py3-none-any.whl
| Download URL | list_packages-1.0.8-py3-none-any.whl |
|---|---|
| Size | 4.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
f0d622b91edf5c156a3727cc7dfbea44962b9aa2328f3d81744a0fd864f1c8f8
|
|
BLAKE2b-256 checksum How to use checksums |
93c5d2e0d4d087765c7d8a53cf8f795ee9e00dfa7470afabb553116b7d5a9dea
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.4
|
Security for list-packages 1.0.8
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.