如何防止tox删除已安装的包?

2 投票
1 回答
610 浏览
提问于 2025-04-17 18:19

我在Windows上用tox测试一个依赖于numpy和scipy的包。

因为pip不知道怎么安装二进制文件,所以我手动安装了numpy和scipy的二进制文件。在测试运行时,tox把numpy和scipy卸载了,结果当然就出错了,因为找不到依赖。

这个问题发生在python 2.5上,使用的是旧版本的numpy和scipy(是为了测试向后兼容性)。

我用来运行tox的python 2.6版本的tox是tox-1.4.2,而我2.5环境中的pip版本是pip-1.2.1。

大约两年前我设置tox测试的时候并没有遇到这个问题。

问题是:有没有办法防止tox卸载numpy和scipy?

额外问题:有没有比tox/pip更适合Windows并且能正确安装二进制文件的替代工具?

1 个回答

1

我想虚拟环境会被重新创建(tox不会卸载包)。

tox之前支持easy_install这个工具,未来可能会重新支持,具体可以查看这个链接:https://bitbucket.org/hpk42/tox/issue/76/support-using-easy_install-especially-on

在此期间,你可以尝试在基础的Python环境中安装numpy和scipy,然后使用sitepackages=True这个选项,具体可以参考这个链接:http://tox.readthedocs.org/en/latest/config.html#confval-sitepackages=True|False

撰写回答