Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

nox session doesn't find pytest installed by poetry

See original GitHub issue

I’m following along the Hypermodern Python series and it seems in Chapter 2, Test automation with Nox there is a conflict between nox and poetry. Specifically when I use the example

import nox

@nox.session(python=["3.8", "3.7"])
def tests(session):"poetry", "install", external=True)"pytest", "--cov")

I get the following error:

nox > Running session tests-3.8
nox > Creating virtual environment (virtualenv) using python3.8 in .nox/tests-3-8
nox > poetry install
Installing dependencies from lock file

No dependencies to install or update

  - Installing testpkg (0.1.0)
nox > Program pytest not found.
nox > Session tests-3.8 failed.

(and the same for tests-3.7)

It seems that installing pytest via poetry as a dev dependency doesn’t put it on the path. In the previous section of Chapter 2, pytest was invoked through poetry and this does work in the nox session as well:'poetry', 'run', 'pytest', '--cov')

Is this an issue with my setup or is it expected that pytest can’t be run as a command when installed by poetry?

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

joezilla86commented, Oct 18, 2020

Your question helped me find the problem. The nox version was 2019.5.30 which did not match what my other computer was using. I ended up actually reinstalling my Ubuntu instance (running as WSL on Windows 10) and have been worked through the same initialization steps again. I realized that the installation of nox didn’t quite work as expected. Running “pip install --user --upgrade nox” did complete the install, but then the nox keyword would return

Command 'nox' not found, but can be installed with:
sudo apt install nox

So I realized I had installed via sudo which installed the 2019.5.30 version. The underlying issue is that using the pip method to install nox did not add it to PATH, so I just needed to add

export PATH="$HOME/.local/bin:$PATH" 

to my .bashrc file and reload the shell. Now it seems to work as expected.

Dominik1123commented, Jun 16, 2020

I created a corresponding issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to use nox with poetry? - python - Stack Overflow
Currently, session.install doesn't support poetry and install just runs pip in the shell. You can activate poetry with a more general method ...
Read more >
nox-poetry documentation
The session.install method automatically honors the Poetry lock file when installing dependencies. This allows you to manage packages used in Nox sessions ......
Read more >
Hypermodern Python 6: CI/CD - Medium
In this sixth and last installment of the Hypermodern Python series, ... run: pip install poetry==1.0.5 ... Add the Nox session shown below....
Read more >
Task runners - Scikit-HEP
Nox. Installing; Introduction; Parametrizing; Useful sessions. Lint; Tests; Docs; Build (pure Python). Examples. A task runner, like make (fully general), ...
Read more >
Welcome to Nox — Nox 2022.11.21 documentation
import nox @nox.session def tests(session): session.install('pytest')'pytest') ... For documentation on running nox , see Command-line usage.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found