英文:
How do I get tox to use interpreters installed by pyenv when using tox installed via pipx?
问题
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 recognize the versions of Python I installed via pyenv?
英文:
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?
答案1
得分: 2
我在找到解决方案之前经历了几次迭代。首先,我找到了tox-pyenv插件,但后来发现该插件自tox 4起已不再使用。
我尝试设置VIRTUALENV_DISCOVERY
环境变量,这是在tox-pyenv插件的README中推荐的,但然后tox
抛出了一堆异常。
所以最后,我通过pyenv local 3.10.12 3.11.4
在我的项目目录中配置了所有必需的版本,现在tox可以正常运行了。
希望这对其他人有所帮助!
附言:如果您真的想在tox 3.x中使用tox-pyenv
,请查看这个答案。如果您通过pipx安装了tox,请尝试使用pipx inject命令将tox-pyenv
安装到与tox
相同的pipx环境中。
英文:
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_DISCOVERY
environment variable recommended in the README of the tox-pyenv plugin but then tox
threw 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.4
and now tox runs just fine.
I hope this helps someone else!
PS. If you really want to use tox-pyenv
with tox 3.x, check out this answer. If you've installed tox via pipx, try the pipx inject command to install tox-pyenv
into the same pipx environment where tox
is installed.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论