Package Audit
Python Package Audit is a lightweight static analysis tool designed to detect unused Python packages
Warning - Ignored directories starting with "." or "_" !
Warning - Unused package detection is not guaranteed to be accurate !
Warning - It is highly recommended to review the results carefully before removing any packages !
Features
- Scans Python files to detect all imported modules
- Maps import names to actual installed PyPI packages
- Tracks both direct and transitive dependencies
- Flags packages that are installed but unused
- Provides optional JSON output for automation pipelines
- Ignores common noise (E.G. folders starting with "." or "_")
- Multithreaded for fast analysis of large projects
Installation
You can install this package via PIP: pip install python-package-audit
Dependencies
This project requires the following Python packages:
- colorama — For colored terminal output
- pipdeptree — For analyzing package dependency trees
Usage
python -m pkgaudit --project "/path/to/your/project-root-directory"
JSON Output
python -m pkgaudit --project "/path/to/your/project-root-directory" --json
Output - Text
[Installed Packages (28)]
build
certifi
charset-normalizer
colorama
docutils
id
idna
jaraco.classes
jaraco.context
jaraco.functools
keyring
markdown-it-py
mdurl
more-itertools
nh3
packaging
pipdeptree
pygments
pyproject_hooks
python-package-audit
pywin32-ctypes
readme_renderer
requests
requests-toolbelt
rfc3986
rich
twine
urllib3
[Used Packages (14)]
Package: ast, Count: 1, Resolve: None
Package: importlib, Count: 1, Resolve: None
Package: json, Count: 2, Resolve: None
Package: os, Count: 2, Resolve: None
Package: subprocess, Count: 1, Resolve: None
Package: sys, Count: 1, Resolve: None
Package: concurrent, Count: 1, Resolve: None
Package: threading, Count: 1, Resolve: None
Package: colorama, Count: 1, Resolve: colorama
Package: argparse, Count: 1, Resolve: None
Package: warnings, Count: 1, Resolve: None
Package: package_analyzer, Count: 2, Resolve: python-package-audit
Package: tempfile, Count: 1, Resolve: None
Package: unittest, Count: 2, Resolve: None
[Unused Packages (25)]
Package: mdurl, Resolve: mdurl
Package: nh3, Resolve: nh3
Package: markdown-it-py, Resolve: markdown-it-py
Package: requests-toolbelt, Resolve: requests-toolbelt
Package: jaraco.functools, Resolve: jaraco.functools
Package: id, Resolve: id
Package: twine, Resolve: twine
Package: charset-normalizer, Resolve: charset-normalizer
Package: rfc3986, Resolve: rfc3986
Package: jaraco.context, Resolve: jaraco.context
Package: pygments, Resolve: Pygments
Package: readme_renderer, Resolve: readme_renderer
Package: build, Resolve: build
Package: packaging, Resolve: packaging
Package: idna, Resolve: idna
Package: pywin32-ctypes, Resolve: pywin32-ctypes
Package: pyproject_hooks, Resolve: pyproject_hooks
Package: more-itertools, Resolve: more-itertools
Package: requests, Resolve: requests
Package: docutils, Resolve: docutils
Package: jaraco.classes, Resolve: jaraco.classes
Package: rich, Resolve: rich
Package: urllib3, Resolve: urllib3
Package: certifi, Resolve: certifi
Package: keyring, Resolve: keyring
Output - JSON
{
"installed_packages_count": 28,
"used_packages_count": 14,
"unused_packages_count": 25,
"installed_packages": [
"build",
"certifi",
"charset-normalizer",
"colorama",
"docutils",
"id",
"idna",
"jaraco.classes",
"jaraco.context",
"jaraco.functools",
"keyring",
"markdown-it-py",
"mdurl",
"more-itertools",
"nh3",
"packaging",
"pipdeptree",
"pygments",
"pyproject_hooks",
"python-package-audit",
"pywin32-ctypes",
"readme_renderer",
"requests",
"requests-toolbelt",
"rfc3986",
"rich",
"twine",
"urllib3"
],
"used_packages": {
"argparse": {
"count": 1,
"resolve": null
},
"warnings": {
"count": 1,
"resolve": null
},
"package_analyzer": {
"count": 2,
"resolve": "python-package-audit"
},
"ast": {
"count": 1,
"resolve": null
},
"importlib": {
"count": 1,
"resolve": null
},
"json": {
"count": 2,
"resolve": null
},
"os": {
"count": 2,
"resolve": null
},
"subprocess": {
"count": 1,
"resolve": null
},
"sys": {
"count": 1,
"resolve": null
},
"concurrent": {
"count": 1,
"resolve": null
},
"threading": {
"count": 1,
"resolve": null
},
"colorama": {
"count": 1,
"resolve": "colorama"
},
"tempfile": {
"count": 1,
"resolve": null
},
"unittest": {
"count": 2,
"resolve": null
}
},
"unused_packages": {
"jaraco.context": {
"resolve": "jaraco.context"
},
"markdown-it-py": {
"resolve": "markdown-it-py"
},
"idna": {
"resolve": "idna"
},
"readme_renderer": {
"resolve": "readme_renderer"
},
"charset-normalizer": {
"resolve": "charset-normalizer"
},
"urllib3": {
"resolve": "urllib3"
},
"packaging": {
"resolve": "packaging"
},
"build": {
"resolve": "build"
},
"id": {
"resolve": "id"
},
"rich": {
"resolve": "rich"
},
"twine": {
"resolve": "twine"
},
"rfc3986": {
"resolve": "rfc3986"
},
"docutils": {
"resolve": "docutils"
},
"pywin32-ctypes": {
"resolve": "pywin32-ctypes"
},
"keyring": {
"resolve": "keyring"
},
"mdurl": {
"resolve": "mdurl"
},
"requests-toolbelt": {
"resolve": "requests-toolbelt"
},
"jaraco.functools": {
"resolve": "jaraco.functools"
},
"requests": {
"resolve": "requests"
},
"certifi": {
"resolve": "certifi"
},
"pygments": {
"resolve": "Pygments"
},
"more-itertools": {
"resolve": "more-itertools"
},
"pyproject_hooks": {
"resolve": "pyproject_hooks"
},
"jaraco.classes": {
"resolve": "jaraco.classes"
},
"nh3": {
"resolve": "nh3"
}
},
"errors": []
}
Metadata
Release files for python-package-audit 0.1.6
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 | Actions |
|---|---|---|---|---|
| python_package_audit-0.1.6.tar.gz | 7.4 kB | Without provenance | Details for python_package_audit-0.1.6.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| python_package_audit-0.1.6-py3-none-any.whl | Python 3 | none | any | Details for python_package_audit-0.1.6-py3-none-any.whl |
Total release size: 14.3 kB
Release files / python_package_audit-0.1.6.tar.gz
| Download URL | python_package_audit-0.1.6.tar.gz |
|---|---|
| Size | 7.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3a0daef2d28ad1e83777333968c8598c995ade96ffacfaf93405c5902b02de05
|
|
BLAKE2b-256 checksum How to use checksums |
97e99c4fba6b81abf7f931460dc0c2151b119425c3f1a8e0687166a5a01d6a0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|
Release files / python_package_audit-0.1.6-py3-none-any.whl
| Download URL | python_package_audit-0.1.6-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5ff20d4470644280d0fc6ccb7a68f42fc4e0645a9cbfccb00017395936cff47d
|
|
BLAKE2b-256 checksum How to use checksums |
1497015e6aa01a20350b3b0bb28c6e345b67f76a8b09548437436261a9e45617
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.6
|
Security for python-package-audit 0.1.6
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.