-2

I just installed pyenv. After that I installed python 3.8.0 in the system

So I have

pyenv versions
  system
* 3.8.0 (set by /home/me/.pyenv/version)

I have the tox.ini

[tox]
envlist = py36,py38
skipsdist = True

[testenv]
# instsall pytest in the virtualenv where commands will be executed
deps = pytest
commands = 
    #NOTE: you can run any command line tool here -not just tests
    pytest

When I tried tox from system, it could not find py38 but when I did pyenv global 3.8.0 it worked. mmm do I have to enter the version? - I asked myself

I then installed python 3.9.16 so now I have

pyenv versions
  system
  3.8.0
* 3.9.16 (set by /home/me/.pyenv/version)

and I added py39 to the envlist in the tox.ini

[tox]
envlist = py36,py38,py39
skipsdist = True

[testenv]
# instsall pytest in the virtualenv where commands will be executed
deps = pytest
commands = 
    #NOTE: you can run any command line tool here -not just tests
    pytest

However now, it always fail.

  • If I am in 3.8.0 it can not find 3.9.16
  • If I am in 3.9.16 it can not find 3.8.0

The curious thing is that inside .tox folder there are three complete folders with py36,py38 and py39

But tox cannot run them all.

How can this be solved?

KansaiRobot
  • 7,564
  • 11
  • 71
  • 150
  • 4
    Use `pyenv global 3.9.16 3.8.0`. From https://github.com/pyenv/pyenv/issues/92 (did you search for e.g. "tox pyenv"?); also directly in the Pyenv README. – 9769953 May 30 '23 at 12:19
  • So if I want to try 5 environments I need to activate the five with pyenv?? – KansaiRobot May 30 '23 at 13:06
  • Well, you'll need to have five Python executables on your PATH. Activating five Python environments at once more or less does that (not exactly, but close enough for this purpose). It's not too dissimilar to installing five Python executables on your system, all in `/usr/bin` or similar. – 9769953 May 30 '23 at 13:18

1 Answers1

1

As mentioned by @9769953, this is explained in the readme of pyenv:

You can activate multiple versions at the same time, including multiple versions of Python2 or Python3 simultaneously. This allows for parallel usage of Python2 and Python3, and is required with tools like tox. For example, to instruct Pyenv to first use your system Python and Python3 (which are e.g. 2.7.9 and 3.4.2) but also have Python 3.3.6, 3.2.1, and 2.5.2 available, you first pyenv install the missing versions, then set pyenv global system 3.3.6 3.2.1 2.5.2.

Jürgen Gmach
  • 5,366
  • 3
  • 20
  • 37