为什么 `tox` 在 Windows 的系统 Python 目录中安装软件包?
why is `tox` installing packages in system Python directory in Windows?
我是 tox
的新手,但我的理解是它为每个测试环境创建了本地虚拟环境。但是,似乎每当我 运行 tox
它首先将软件包安装到系统 Python 安装然后在那里也安装任何依赖项。
这是我能展示的最简单的例子:
我的tox.ini
就是:
[tox]
envlist = py27
[testenv]
commands = pytest
deps =
pytest
然后下面的一系列命令显示pytest
没有安装,但是在tox
运行的最后,安装在系统python路径下:
> which pytest
which: no pytest in (/cygdrive/c/Program Files (x86....
> tox
[... lots of output ...]
___________________________________ summary ___________________________________
py27: commands succeeded
congratulations :)
然后,
> which pytest
/cygdrive/c/Python27/Scripts/pytest
此外,我看到我正在测试的包也安装在系统 python 目录中。
tox
不应该在本地生成虚拟环境吗?我看到创建了一个 .tox/py27
目录,但它看起来像 Linux 风格的安装,带有 bin
目录而不是 Scripts
。这是 tox
的预期行为吗?
看起来您在系统的 PATH
环境变量上使用了 Windows-native Python,甚至在 Cygwin 的 /bin
路径之前以某种方式被插入,所以 tox
正在寻找并尝试 运行 Python 而不是 Cygwin 的 Python。一般来说,你不应该使用 Cygwin 的 Windows Python 除非有非常具体的原因。
根据评论,您提到您安装了 TortoiseHG。我不知道 TortoiseHG 在 Windows 上的确切工作方式,但由于 Mercurial 是用 Python 编写的,TortoiseHG 必须带有 Python 解释器,或者至少使用任何 Python 它在 Windows 上找到的解释器(可能使用 virtualenv),所以如果 TortoiseHG 有一个 PATH
条目确保它仍然在你的 Cygwin {/,/usr/,/usr/local/}bin
.
之后
我是 tox
的新手,但我的理解是它为每个测试环境创建了本地虚拟环境。但是,似乎每当我 运行 tox
它首先将软件包安装到系统 Python 安装然后在那里也安装任何依赖项。
这是我能展示的最简单的例子:
我的tox.ini
就是:
[tox]
envlist = py27
[testenv]
commands = pytest
deps =
pytest
然后下面的一系列命令显示pytest
没有安装,但是在tox
运行的最后,安装在系统python路径下:
> which pytest
which: no pytest in (/cygdrive/c/Program Files (x86....
> tox
[... lots of output ...]
___________________________________ summary ___________________________________
py27: commands succeeded
congratulations :)
然后,
> which pytest
/cygdrive/c/Python27/Scripts/pytest
此外,我看到我正在测试的包也安装在系统 python 目录中。
tox
不应该在本地生成虚拟环境吗?我看到创建了一个 .tox/py27
目录,但它看起来像 Linux 风格的安装,带有 bin
目录而不是 Scripts
。这是 tox
的预期行为吗?
看起来您在系统的 PATH
环境变量上使用了 Windows-native Python,甚至在 Cygwin 的 /bin
路径之前以某种方式被插入,所以 tox
正在寻找并尝试 运行 Python 而不是 Cygwin 的 Python。一般来说,你不应该使用 Cygwin 的 Windows Python 除非有非常具体的原因。
根据评论,您提到您安装了 TortoiseHG。我不知道 TortoiseHG 在 Windows 上的确切工作方式,但由于 Mercurial 是用 Python 编写的,TortoiseHG 必须带有 Python 解释器,或者至少使用任何 Python 它在 Windows 上找到的解释器(可能使用 virtualenv),所以如果 TortoiseHG 有一个 PATH
条目确保它仍然在你的 Cygwin {/,/usr/,/usr/local/}bin
.