我正在尝试启动并运行 pyenv(Mac OS X),因此我可以使用 tox/detox 来测试代码与多个 python 环境。我能够安装多个 python3 版本,然后我pyenv global
在所有版本上都使用了。之后,pyenv versions
返回此列表:
system
* 3.2.6 (set by /Users/Workspace/.pyenv/version)
3.3.6
3.4.6
3.5.3
3.6.1
但是,只有 3.4 和 3.5 被识别(以及 2.7.8,我认为它是“系统”):
Geoffreys-MBP:pydnmr-tox Workspace$ python --version
Python 2.7.8
Geoffreys-MBP:pydnmr-tox Workspace$ python3.2 --version
-bash: python3.2: command not found
Geoffreys-MBP:pydnmr-tox Workspace$ python3.3 --version
-bash: python3.3: command not found
Geoffreys-MBP:pydnmr-tox Workspace$ python3.4 --version
Python 3.4.3
Geoffreys-MBP:pydnmr-tox Workspace$ python3.5 --version
Python 3.5.2
Geoffreys-MBP:pydnmr-tox Workspace$ python3.6 --version
-bash: python3.6: command not found
任何想法是什么导致了这种行为?tox/detox 同样找不到除了 3.4/3.5 之外的任何 Python 版本。
编辑:似乎 pyenv 已经安装了所有环境,但是python3.x
命令没有找到它们。python3.4
并且python3.5
正在工作,因为他们找到了以前的顶级安装。pyenv which python3.x.y
对比结果python3.x [--version]
如下所示。
$ pyenv which python3.2
/Users/Workspace/.pyenv/versions/3.2.6/bin/python3.2
$ python3.2 --version
-bash: python3.2: command not found
$ python3.2
-bash: python3.2: command not found
pyenv which python3.3
/Users/Workspace/.pyenv/versions/3.3.6/bin/python3.3
$ python3.3 --version
-bash: python3.3: command not found
$ pyenv which python3.4
/usr/local/bin/python3.4 # old install
$ python3.4 --version
Python 3.4.3 # not 3.4.6 installed by pyenv
$ pyenv which python3.4.6
pyenv: python3.4.6: command not found
$ python3.4.6 --version
-bash: python3.4.6: command not found
$ pyenv which python3.5
/Users/Workspace/.pyenv/versions/3.5.3/bin/python3.5
$ python3.5 --version
Python 3.5.2 #Linked to my old 3.5.2 install instead of pyenv 3.5.3 install
$ pyenv which python3.6
/Users/Workspace/.pyenv/versions/3.6.1/bin/python3.6
$ python3.6 --version
-bash: python3.6: command not found
但是,按照以下答案中的建议安装 tox-pyenv 允许 tox 查找和使用所有这些环境!