I installed tox globally via pipx as follows:
pipx install tox
tox --version
4.6.4
I have installed Python 3.10 via pyenv as follows:
pyenv install 3.10.12
However, when I run tox with a py310 environment, I get the following error message:
skipped because could not find python interpreter with spec(s): py310
How can I get tox (installed via pipx) to recognise the versions of Python I installed via pyenv?
I went through a few iterations before I found a solution. First of all I found the tox-pyenv plugin but it turns out that the plugin has been deprecated since tox 4.
I tried setting the
VIRTUALENV_DISCOVERYenvironment variable recommended in the README of the tox-pyenv plugin but thentoxthrew a bunch of exceptions.So in the end I configured all required versions in my project directory via
pyenv local 3.10.12 3.11.4and now tox runs just fine.I hope this helps someone else!
PS. If you really want to use
tox-pyenvwith tox 3.x, check out this answer. If you've installed tox via pipx, try the pipx inject command to installtox-pyenvinto the same pipx environment wheretoxis installed.