← 返回命令列表

Linux command

nox 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Run default session

nox

Run specific session

nox -s [tests]

List available sessions

nox -l

Run with Python version

nox -p [3.12]

Reuse virtualenv and skip install steps

nox -R

Run with a specific venv backend

nox --force-venv-backend [uv]

Run with extra arguments passed to the session

nox -s [tests] -- [pytest-args]

说明

Nox is a Python automation tool that automates testing across multiple Python environments. Sessions are defined as Python functions in a noxfile.py, making configuration flexible and programmable compared to tox's INI-based approach. Nox supports multiple virtualenv backends including virtualenv, venv, uv, conda, and mamba. The `-R` flag enables fast development iteration by reusing virtualenvs and skipping package installation.

参数

-s, --sessions _name_
Run specific sessions.
-l, --list
List available sessions and exit.
-r, --reuse-existing-virtualenvs
Reuse existing virtualenvs instead of recreating them.
-R
Reuse virtualenvs and skip install steps (combines -r and --no-install).
-p, --python _version_
Filter sessions by Python version.
-P, --force-python _version_
Override Python versions specified in the Noxfile.
-f, --noxfile _file_
Nox configuration file (default: noxfile.py).
-k _expression_
Filter sessions by keyword expression.
-t, --tags _tag_
Filter sessions by tag.
-x, --stop-on-first-error
Stop after the first session failure.
--no-install
Skip install commands when reusing virtualenvs.
-db, --default-venv-backend _backend_
Default venv backend: virtualenv, venv, uv, conda, mamba, micromamba, none.
-fb, --force-venv-backend _backend_
Force a specific venv backend for all sessions.
--envdir _dir_
Directory for virtualenvs (default: .nox).
--report _file_
Output a JSON report of session results.

FAQ

What is the nox command used for?

Nox is a Python automation tool that automates testing across multiple Python environments. Sessions are defined as Python functions in a noxfile.py, making configuration flexible and programmable compared to tox's INI-based approach. Nox supports multiple virtualenv backends including virtualenv, venv, uv, conda, and mamba. The `-R` flag enables fast development iteration by reusing virtualenvs and skipping package installation.

How do I run a basic nox example?

Run `nox` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -s, --sessions _name_ do in nox?

Run specific sessions.