Python Package Audit is a lightweight static analysis tool designed to detect unused Python packages
Project description
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": []
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file python_package_audit-0.1.6.tar.gz.
File metadata
- Download URL: python_package_audit-0.1.6.tar.gz
- Upload date:
- Size: 7.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a0daef2d28ad1e83777333968c8598c995ade96ffacfaf93405c5902b02de05
|
|
| MD5 |
c9a420951032ffb96b5d60b206589bcd
|
|
| BLAKE2b-256 |
97e99c4fba6b81abf7f931460dc0c2151b119425c3f1a8e0687166a5a01d6a0f
|
File details
Details for the file python_package_audit-0.1.6-py3-none-any.whl.
File metadata
- Download URL: python_package_audit-0.1.6-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ff20d4470644280d0fc6ccb7a68f42fc4e0645a9cbfccb00017395936cff47d
|
|
| MD5 |
51893a1fa56b4813706570e4bebb82e3
|
|
| BLAKE2b-256 |
1497015e6aa01a20350b3b0bb28c6e345b67f76a8b09548437436261a9e45617
|