Registry / devops / deptry

deptry

JSON →
library0.25.1pypypiunverified

Deptry is a command-line utility for Python projects that identifies unused, missing, and transitive dependencies. Maintained by Astral (the team behind Ruff), it's actively developed with regular releases, often in sync with the broader Astral ecosystem.

pip install deptry
INSTALL
IMPORT
SIG · DEPTRY
D
deptry
devopspythonv0.25.1
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Run Deptry on the current directory to check for dependency issues. This will scan source files and project configuration to identify unused, missing, or transitive dependencies. Configure via `pyproject.toml` for more specific checks.

deptry .
deptry --version
Debug
Known issues
breakingDeptry's ownership and repository moved from `s-weigand/deptry` to `astral-sh/deptry`. While the core CLI interface largely remained consistent, ensure you are installing the package from the official source and referring to the documentation at `deptry.astral.sh`. Older guides or references might point to the archived repository.
fix
Verify your `pip install` command (it should be `pip install deptry`) and documentation sources. The current official `deptry` is maintained by Astral.
affects: All versions (post-migration, roughly >= 0.12.0)
breakingThe `--requirements-txt` CLI flag was removed. Deptry now relies on auto-discovery of dependency files (e.g., `requirements.txt`, `pyproject.toml`) or explicit configuration within `pyproject.toml`.
fix
Remove the `--requirements-txt` flag from your commands. Deptry will automatically detect common dependency files. For explicit control, configure `dependency_file_paths` in `[tool.deptry]` within your `pyproject.toml`.
affects: >= 0.12.0
gotchaDeptry may sometimes report false positives (unused dependencies) or false negatives (missing dependencies). This can occur due to dynamic imports, specific project structures, or dependencies used only in non-source files (e.g., configurations, CI scripts).
fix
Configure `ignore_unused`, `ignore_missing`, `ignore_transitive`, and `exclude` paths in your `pyproject.toml` under `[tool.deptry]` to fine-tune the analysis for your project's specific needs. Use comments to explain ignores for future maintainers.
affects: All versions
gotchaDeptry requires Python 3.10 or newer. Attempting to run it with older Python versions will result in an installation error or runtime failures.
fix
Ensure your project's Python environment and the environment where Deptry is installed is 3.10 or higher. Upgrade Python if necessary.
affects: All versions
Errors
Common errors & fixes
deptry not working virtualenv / deptry ModuleNotFoundError
Deptry needs to be installed within the project's virtual environment to properly access the metadata of the installed packages. Installing it globally prevents it from seeing project-specific dependencies.
fix
Activate your project's virtual environment, then install deptry using `pip install deptry`, `poetry add --group dev deptry`, or `uv add --dev deptry`.
DEP001 'some_module' imported but missing from the dependency definitions
This error occurs when a module is imported in your code but is not explicitly listed as a direct dependency in your `pyproject.toml` or `requirements.txt` file, or if it's a first-party module not recognized by deptry.
fix
Add the corresponding package as a direct dependency to your `pyproject.toml` or `requirements.txt`. If it's a first-party module, configure `deptry` to recognize it using `known_first_party` in your `pyproject.toml` (e.g., `[tool.deptry] known_first_party = ['your_local_module']`).
DEP002 'some_package' defined as a dependency but not used in the codebase
This warning indicates that a dependency is listed in your project's manifest but deptry doesn't detect any imports from it within your codebase, or it's a development dependency being scanned incorrectly.
fix
If the dependency is genuinely unused, remove it from your project's dependencies. If it is used in a way deptry doesn't detect (e.g., dynamic imports, CLI tools), you can ignore the specific rule for that package (`deptry --per-rule-ignores DEP002=some_package`) or exclude relevant files/directories (`deptry --exclude 'path/to/files/*'`). Ensure development dependencies are correctly categorized.
DEP003 'some_transitive_module' imported but it is a transitive dependency
This warning occurs when your code directly imports a module whose parent package is not a direct dependency, but rather a dependency of another package listed in your project's direct dependencies.
fix
Add the `some_transitive_module`'s corresponding package as a direct dependency to your `pyproject.toml` or `requirements.txt` to explicitly declare its usage. Alternatively, you can ignore this specific violation using `--ignore DEP003` or `--per-rule-ignores DEP003=some_transitive_package` if you understand and accept the implications.
Upgrade
Version history
0.25.1latest on PyPI · released Mar 18, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
32 hits · last 30 days
node
26
OpenAI (training)
1
Resources
deptry — pip install deptry · libregistry