11

I have a project on GitHub with a tox.ini file:

[tox]
envlist = py3

[testenv]
deps = -rrequirements.txt
commands =
    pytest --doctest-modules

It works well. But when I replace "py3" with "py37", it fails with the error:

ERROR:  py37: InterpreterNotFound: python3.7

As far as I know, tox should support Python 3.7. Is this a problem specifically with tox on github?

sinoroc
  • 18,409
  • 2
  • 39
  • 70
Erel Segal-Halevi
  • 33,955
  • 36
  • 114
  • 183
  • Is Python 3.7 installed on the machine? Is it accessible, for example as `python3.7` on the command line? – sinoroc Jul 30 '20 at 20:23
  • @sinoroc The project is on GitHub, and tox is run by "GitHub actions", so it is not my machine. How can I check if python3.7 is installed on their machine? – Erel Segal-Halevi Jul 30 '20 at 20:29
  • 1
    I see, it wasn't clear from the question. I'm not familiar with _Github actions_. But I guess a good first step would be to show the _github actions_ configuration (the workflows?), so that users familiar with it can help sort it out. – sinoroc Jul 30 '20 at 21:42
  • You can check here for software installed on the runners https://docs.github.com/en/actions/reference/software-installed-on-github-hosted-runners. Using https://github.com/actions/setup-python will probably fix your problem. – riQQ Aug 01 '20 at 10:00
  • @riQQ thanks! this seems helpful, but how can I know which version of Ubuntu is used? – Erel Segal-Halevi Aug 01 '20 at 20:24
  • @ErelSegal-Halevi are you using `ubuntu-latest`? "The ubuntu-latest YAML workflow label still uses the Ubuntu 18.04 virtual environment." – riQQ Aug 02 '20 at 17:47

2 Answers2

18

In the tox.ini file, write python3.7 instead of py37 and you will see that it works.

All credits to the Github user glinskyc for his thread on Github issues.

Also make sure that you are using the latest version for tox, that is 3.23.1

Deepak Tatyaji Ahire
  • 4,883
  • 2
  • 13
  • 35
  • 9
    I just tried this myself. It *seemed* to work, but then I noticed it runs everything with the default Python (3.9 in my case)! I get messages with paths like `/[pathredacted]/.tox/python3.7/lib/python3.9/site-packages/` in them ("python3.7" is the tox environment, and "python3.9" is the Python installed into it). I won't say it *never* works, but it apparently doesn't work on Linux with tox 3.24.3. – Tim Pederick Aug 31 '21 at 13:37
  • July 2022 I still receive the issue pointed out By Tim Pederick, also on Ubuntu 22.04, and now my code is breaking because it is running Python3.10 even though tox says it's running Python3.9 – Justin Furuness Jul 01 '22 at 05:14
  • 2
    @TimPederick is right, this is just using the most recent available python and not the specified one. You can change it to something crazy like `python9000` and it'll still just "work" because that's not a predefined tag like `py37` is. – Izkata Jul 20 '22 at 20:56
0

From a combination of the answers and resources provided here. What I did was:

  • through pyenv I did install all python version I needed.
  • I did symlinked all of them in a bin folder which was already in my PATH. Symlinks already were named the same as tox was expecting: python3.7, python3.8 and pypy3
  • no renaming in tox was required
davidmpaz
  • 1,194
  • 15
  • 18