Vermin
Vermin is a static analysis tool that concurrently detects the minimum Python versions required to run code. It is an actively maintained project with frequent updates, often adding support for the latest Python versions (e.g., 3.14, 3.13, 3.12) and expanding its rule set. It functions by parsing Python code into an abstract syntax tree (AST) and matching it against an extensive internal database of Python language features.
Common errors
-
'vermin' is not recognized as an internal or external command, operable program or batch file.
cause The `vermin` executable is not in your system's PATH, or you're trying to run it in a Python REPL instead of a shell.fixEnsure `pip`'s binary directory is in your system's PATH, or invoke it directly via `python3 -m vermin <path>`. Always run `vermin` from your system's command line (shell), not inside a Python interpreter. -
SyntaxError: invalid syntax (when trying to run `vermin /path/to/file.py` in Python REPL)
cause You are attempting to execute a shell command (`vermin`) directly within the Python interactive interpreter (REPL).fixExit the Python REPL (e.g., by typing `exit()` or pressing Ctrl+D) and run the `vermin /path/to/file.py` command from your operating system's command line (bash, zsh, cmd, PowerShell, etc.). -
Minimum required versions: X.Y, Z.W\nTarget versions not met: A.B, C.D\n(exit code 1)
cause This is Vermin's intended output when your code contains features requiring a Python version higher than one or more of your specified `--target` versions. The exit code `1` indicates that the target versions were violated.fixThis is not an error but a diagnostic. Either update your code to be compatible with the `--target` versions, increase your `--target` versions to match the minimums detected by Vermin, or use `--exclude` to ignore specific findings. When using `vermin --violations`, only the problematic lines are shown.
Warnings
- breaking Vermin v1.6.0 removed support for running Vermin itself using Python 2.x interpreters. While Vermin can still *detect* Python 2.x features in your code, the tool itself must be executed with Python 3+.
- gotcha Detection of Union types (`X | Y` as per PEP 604) became an opt-in feature in v1.5.2 due to potential inaccuracies. It's disabled by default.
- breaking The `--lax` mode was entirely removed in Vermin v1.4.0. This option was previously deprecated and is no longer available.
- gotcha When using generic or literal annotations (e.g., `type X = SomeType` or `list[str]`), Vermin might suggest enabling annotation evaluation to get accurate results if annotations are disabled by default (e.g., due to `from __future__ import annotations`).
Install
-
pip install vermin
Imports
- vermin
import vermin as V
Quickstart
# Analyze a Python file or directory vermin /path/to/your/project