---
source: https://iinventedlight.com/library/notes/nox-sessions.md
title: "Define and parametrize Nox sessions in a noxfile"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "Apache-2.0 (Nox docs); Apache-2.0 (Nox source); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Nox docs, Configuration & API; Nox source, sessions.py. Apache-2.0; Apache-2.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-python: Nox sessions"
tags: [nox, noxfile, sessions, parametrize]
client: Librarian
sources:
  - id: S1
    title: "Configuration & API"
    publisher: Nox docs
    url: https://nox.thea.codes/en/stable/config.html
    accessed: 2026-11-19
    license: "Apache-2.0"
  - id: S2
    title: "sessions.py"
    publisher: Nox source
    url: https://raw.githubusercontent.com/wntrblm/nox/main/nox/sessions.py
    accessed: 2026-11-19
    license: "Apache-2.0"
---
# Define and parametrize Nox sessions in a noxfile
**Answer:** By default, Nox looks for configuration in `noxfile.py`. Pass `--noxfile` when running `nox` if you want a different file. Nox sessions use standard Python functions, each decorated with `@nox.session`. In the example, `tests` calls `session.run('pytest')`.

## Defaults and descriptions

By default, all sessions will be run if no sessions are specified. Pass `default=False` in the `@nox.session(...)` decorator to drop a session from that list. The `nox.options.sessions` option can also name the default list. You can add a description to your session using a docstring. The first line will be shown when listing the sessions. The `nox --list` command will show available sessions. You can also configure sessions to run against multiple Python versions and parametrize sessions.

| noxfile.py | session |
|---|---|
| `@nox.session` | `session.run` |
| `nox.options.sessions` | `default=False` |
| docstring | `nox --list` |
| parametrize | Python versions |

## virtualenv

In the implementation, `session.virtualenv` is the virtualenv that all commands are run in. If a virtualenv has not been created for this session, that property raises. Session names used on disk are normalized to be a "safe" filesystem path for a virtualenv. A name that is too long may be hashed.

## See also

- [python-venv](https://iinventedlight.com/library/notes/python-venv/)

## Claims

- id: C1
  claim: Nox reads noxfile.py by default and defines sessions with @nox.session.
  source: S1
  evidence: "Nox sessions are configured via standard Python functions that are decorated"

- id: C2
  claim: If no sessions are named, Nox runs all of them unless default=False or nox.options.sessions says otherwise.
  source: S1
  evidence: "By default, all sessions will be run if no sessions are specified."

- id: C3
  claim: The session object's virtualenv is the environment that all commands are run in.
  source: S2
  evidence: "The virtualenv that all commands are run in."

## Sources

- [S1] Configuration & API. Nox docs. https://nox.thea.codes/en/stable/config.html . License: Apache-2.0. Accessed 2026-11-19.

- [S2] sessions.py. Nox source. https://raw.githubusercontent.com/wntrblm/nox/main/nox/sessions.py . License: Apache-2.0. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Nox docs, Configuration & API; Nox source, sessions.py. Apache-2.0; Apache-2.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
