{"id":2138,"library":"nox","title":"Nox","description":"Nox is a command-line tool that automates development tasks like testing and linting across multiple Python environments. It utilizes a standard Python file (`noxfile.py`) for configuration, creating isolated virtual environments for each defined session. This approach provides programmatic control and reproducibility, installing specified dependencies and running commands within each isolated environment. As of version 2026.2.9, Nox is actively maintained with a regular release cadence, often following a calendar versioning scheme.","status":"active","version":"2026.2.9","language":"en","source_language":"en","source_url":"https://github.com/wntrblm/nox","tags":["testing","automation","virtual environments","development tools","cli"],"install":[{"cmd":"pip install nox","lang":"bash","label":"Install globally with pip"},{"cmd":"pipx install nox","lang":"bash","label":"Recommended: Install with pipx for isolated CLI"}],"dependencies":[],"imports":[{"symbol":"nox","correct":"import nox"},{"note":"Decorator used to define a session function in noxfile.py","symbol":"session","correct":"@nox.session"},{"note":"Type hint for the session object passed to decorated functions","symbol":"Session","correct":"def my_session(session: nox.Session):"}],"quickstart":{"code":"# noxfile.py\nimport nox\n\n@nox.session(python=[\"3.9\", \"3.10\", \"3.11\"])\ndef tests(session):\n    \"\"\"Run the test suite with pytest.\"\"\"\n    session.install(\"pytest\")\n    session.run(\"pytest\", \"tests/\")\n\n@nox.session\ndef lint(session):\n    \"\"\"Lint source code with Flake8 and Black.\"\"\"\n    session.install(\"flake8\", \"black\")\n    session.run(\"flake8\", \"src/\", \"tests/\", \"noxfile.py\")\n    session.run(\"black\", \"--check\", \"src/\", \"tests/\", \"noxfile.py\")\n\n# To run these sessions, save the above as noxfile.py in your project root\n# and execute 'nox' in your terminal. For specific sessions, use 'nox -s tests' or 'nox -s lint'.\n# To run multiple Python versions, nox will create virtualenvs for each specified version.\n# Make sure you have python3.9, python3.10, python3.11 interpreters available on your PATH.","lang":"python","description":"Create a `noxfile.py` in your project root to define test, lint, and format sessions. Nox will automatically create isolated virtual environments for each session, install dependencies, and execute commands. Run `nox` to execute all defined sessions, or `nox -s <session_name>` to run a specific one."},"warnings":[{"fix":"Update `pip install` commands to `pip install nox`, rename `nox.py` to `noxfile.py`, and rewrite session configurations to use imperative `session.install()` and `session.run()` calls. Ensure Python 3.5+ is used for Nox itself.","message":"The library's package name changed from `nox-automation` to `nox`, and the configuration file from `nox.py` to `noxfile.py`. Support for Python 2.7 was dropped, and session actions shifted from declarative to imperative.","severity":"breaking","affected_versions":"<=2018.8.23"},{"fix":"Install `nox` using `pip install nox` (preferably `pipx install nox`) outside of any project-specific virtual environment. Do not add `nox` to your project's `requirements.txt` or `pyproject.toml` dependencies.","message":"Nox is designed to be installed globally (or via `pipx`) in your system's Python environment, *not* within a project's virtual environment. It manages its own isolated virtual environments for each session it runs.","severity":"gotcha","affected_versions":"All"},{"fix":"Always include `session.install('your-dependency')` at the beginning of your Nox session functions for all required packages. Do not rely on packages being available from your global environment or other sessions.","message":"Each Nox session runs in a freshly created, isolated virtual environment. Any dependencies required for a session's commands (e.g., `pytest`, `flake8`) must be explicitly installed within that session using `session.install()`.","severity":"gotcha","affected_versions":"All"},{"fix":"If encountering issues with `uv` environments not clearing as expected, ensure your `noxfile.py` or `nox` configuration that uses `uv` backend accounts for this change. Nox 2026.2.9 was released to support this `uv` change internally.","message":"When using `uv` as a backend, `uv` version 0.10.0 and later now require the `--clear` flag to clear an environment.","severity":"breaking","affected_versions":">=2026.2.9"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}