Nox
Nox is a command-line tool that automates tasks like testing and linting in isolated virtual environments across one or more Python versions. You define sessions as Python functions in a noxfile.py, and Nox creates an environment for each session, installs dependencies, and runs your commands.
Installation and Setup
Install it from PyPI:
Key Features
- Defines functions in
noxfile.pyusing@nox.sessiondecorator. - Creates isolated environments per session using a selectable backend. It defaults
virtualenv, but supportsuv, Conda,mamba,micromamba, andvenv. - Runs sessions across multiple Python versions and filters by Python version at the CLI with
--python. - Builds test matrices with
nox.parametrize, including readable IDs. - Filters which sessions run using pytest-style keywords (
-k/--keywords) and tags (-t/--tags). - Reuses environments between runs with
--reuse-venv=yes(or-r) to speed up local workflows. - Supports optional helpers like
nox-poetryandnox-uvfor tighter integration with Poetry anduvworkflows.
Usage
Create a noxfile.py in your project directory and define sessions with an optional list of Python versions:
Python
import nox
@nox.sessionp(python=["3.12", "3.13", "3.14"])
def tests(session):
session.install("pytest")
session.run("pytest", "-q")
Run all sessions:
Shell
$ nox
List available sessions:
Shell
$ nox -l
Select sessions to run:
Shell
$ nox -s lint tests
Choose Python versions at the CLI:
Shell
$ nox --python 3.12
Reuse environments to speed up local runs:
Shell
$ nox --reuse-venv=yes
Switch the default backend, with optional fallbacks:
Shell
$ nox --default-venv-backend "uv|virtualenv"
By Leodanis Pozo Ramos • Updated Dec. 17, 2025