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:

Windows PowerShell
(venv) PS> py -m pip install nox
Shell
(venv) $ python -m pip install nox

Key Features

  • Defines functions in noxfile.py using @nox.session decorator.
  • Creates isolated environments per session using a selectable backend. It defaults virtualenv, but supports uv, Conda, mamba, micromamba, and venv.
  • 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-poetry and nox-uv for tighter integration with Poetry and uv workflows.

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