使用pipx安装的tox时,如何让tox使用由pyenv安装的解释器?

huangapple go评论86阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年8月4日 22:31:27
  • 转载请务必保留本文链接:https://go.coder-hub.com/76836871.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定