deptry
A command line utility to check for unused, missing and transitive dependencies in a Python project.
What it is and what it does
Deptry is a command-line tool that audits Python project dependencies by scanning source code for actual imports and comparing them against what your project declares. It works with Poetry, pip, PDM, uv, and any project following PEP 621, identifying three main problems: dependencies you've declared but never use, dependencies you import but forgot to declare, and transitive dependencies that may cause issues. You run it from your project root within its virtual environment, and it reports each issue with a file location and error code.
The tool is written in Rust for performance and distributed as prebuilt wheels for most platforms. It's actively maintained, supports Python 3.10 through 3.14, and can be configured via command-line flags or a `[tool.deptry]` section in pyproject.toml. Its main dependencies are lightweight CLI and parsing libraries (click, colorama, packaging, requirements-parser, tomli).
Use it for:
- Enforce clean dependency hygiene in CI/CD pipelines by catching unused or missing declarations before merge
- Audit existing projects to identify and remove bloated or forgotten dependencies that slow installation
- Validate that dev-only dependencies (like test frameworks) aren't accidentally imported in production code
- Detect missing transitive dependencies that could break if an intermediate package changes its exports
- Integrate into pre-commit hooks to catch dependency issues during local development
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Scans Python projects to detect unused, missing, and transitive dependency issues by analyzing imports and comparing them against declared dependencies in Poetry, pip, PDM, uv, or PEP 621 projects.
Yes. Deptry solves a real problem—dependency drift—that most Python projects accumulate over time. It's actively maintained, has no known vulnerabilities, uses a permissive license, and the medium install friction (Python 3.10+ requirement, virtual-environment-only) is a reasonable trade-off for a development tool. Install it as a dev dependency and run it in CI.
Install
deptry on PyPI
pip
pip install deptryuv
uv add deptrypoetry
poetry add deptryInstalling deptry
Before you install
Medium install friction: requires Python 3.10+ and must be installed in the project's own virtual environment, not globally. Prebuilt wheels available for CPython and PyPy across common platforms. Active maintenance with recent releases.
License in practice
MIT license permits commercial and private use with minimal restrictions; you may use, modify, and distribute deptry freely provided you include the license notice.
Quickstart
pip install deptry
# Then from your project root:
deptry .
# Output shows issues like:
# foo/bar.py:1:0: DEP004 'numpy' imported but declared as a dev dependency
Must be installed in the project's own virtual environment and run from the project root directory; requires Python 3.10 or later.
Verify before relying
- Accuracy of import detection across different Python syntax patterns and dynamic imports
- Performance characteristics on large codebases with thousands of files
- Support scope for less common dependency declaration formats beyond the listed tools
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 5 — click, colorama, packaging, requirements-parser, tomli |
| Maintenance | actively maintained — 149 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 8,838,663/month — #1,590 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: deptry-0.25.1-cp310-abi3-macosx_10_12_x86_64.whl; deptry-0.25.1-cp310-abi3-macosx_11_0_arm64.whl; deptry-0.25.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; deptry-0.25.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; deptry-0.25.1-cp310-abi3-musllinux_1_1_aarch64.whl; deptry-0.25.1-cp310-abi3-musllinux_1_1_x86_64.whl; deptry-0.25.1-cp310-abi3-win_amd64.whl; deptry-0.25.1-cp310-abi3-win_arm64.whl; deptry-0.25.1-pp311-pypy311_pp73-macosx_10_12_x86_64.whl; deptry-0.25.1-pp311-pypy311_pp73-macosx_11_0_arm64.whl; deptry-0.25.1-pp311-pypy311_pp73-manylinux_2_17_aarch64.manylinux2014_aarch64.whl; deptry-0.25.1-pp311-pypy311_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl; deptry-0.25.1-pp311-pypy311_pp73-musllinux_1_1_aarch64.whl; deptry-0.25.1-pp311-pypy311_pp73-musllinux_1_1_x86_64.whl; deptry-0.25.1-pp311-pypy311_pp73-win_amd64.whl
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
fawltydepsFawltydeps identifies undeclared dependencies…
permissive · top 15,000 on PyPI
pip-check-reqsAudits Python project imports against…
permissive · top 15,000 on PyPI
cppcleancppclean analyzes C++ source code to identify…
permissive · top 15,000 on PyPI
pdmPDM is a modern Python package and dependency…
unclear · top 5,000 on PyPI
creosoteCreosote scans your Python project's source…
permissive · top 5,000 on PyPI
flawfinderFlawfinder scans C/C++ source code to identify…
copyleft · top 15,000 on PyPI
flake8-requirementsA flake8 plugin that validates whether imported…
permissive · top 15,000 on PyPI
pysentry-rsPySentry scans Python projects for known…
permissive · top 15,000 on PyPI
rootpathDetects a Python project or package root…
permissive · top 15,000 on PyPI
dependency-groupsParses and resolves PEP 735 dependency groups…
permissive · top 5,000 on PyPI