Skip to content
Latchkey

nox session failed in CI

nox runs each session in its own virtualenv and a command inside a session exited non-zero (or the session's interpreter was missing). nox marks that session failed and exits non-zero, summarizing which sessions passed and failed.

What this error means

nox ends with "Sessions failed: tests-3.12" and a non-zero exit, after a command in the session (pytest, lint) returned an error.

python
nox > Command pytest failed with exit code 1
nox > Session tests-3.12 failed.
Sessions failed: tests-3.12

Common causes

A command in the session exited non-zero

The real failure (a failing test, a lint error) happened inside the session; nox just surfaces the non-zero exit.

The session interpreter is unavailable

A @nox.session(python="3.12") cannot run if 3.12 is not installed, failing the session before commands run.

How to fix it

Read the failing command output

  1. Scroll to the "Command X failed" line and the output above it.
  2. Fix the underlying failure (the test, lint, or build error).
  3. Re-run the specific session with nox -s <session>.
Terminal
nox -s tests-3.12

Ensure session interpreters exist

Install the Python versions your sessions target so nox can create their venvs.

.github/workflows/ci.yml
- uses: actions/setup-python@v5
  with:
    python-version: '3.12'

How to prevent it

  • Provision all interpreters nox sessions target in CI.
  • Run failing sessions individually to isolate the command.
  • Keep session dependency lists pinned for reproducibility.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →