我的 tox.ini 文件在 Windows 上看起来像这样
[tox]
envlist = cpy27,dpy27
skip_missing_interpreters = True
[testenv]
basepython =
cpy27: C:\Python27\python.exe
dpy27: D:\Python27\python.exe
deps =
pytest
commands = py.test tests
但是,当我在命令提示符中执行“tox”时,出现了这个错误。为什么会这样?如果我在命令行上运行python setup.py install,我就看不到任何错误。
Installing collected packages: coverage, pytest-cov, requests, psutil, pytz, enum, argh, pathtools, PyYAML, watchdog, monit
Running setup.py install for PyYAML: started
Running setup.py install for PyYAML: finished with status 'error'
Complete output from command d:\repos\foo\.tox\dpy27\scripts\python.exe -u -c "import setuptools, tokenize;__file__='c:\\users\\foo\\appdata\\local\\temp\\pip-build-bbx8kz\\PyYAML\\setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record c:\users\vikone\appdata\local\temp\pip-zyvbbh-record\install-record.txt --single-version-externally-managed --compile --install-headers d:\repos\foo\.tox\dpy27\include\site\python2.7\PyYAML:
running install
running build
running build_py
creating build
creating build\lib.win-amd64-2.7
creating build\lib.win-amd64-2.7\yaml
copying lib\yaml\composer.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\constructor.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\cyaml.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\dumper.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\emitter.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\error.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\events.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\loader.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\nodes.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\parser.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\reader.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\representer.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\resolver.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\scanner.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\serializer.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\tokens.py -> build\lib.win-amd64-2.7\yaml
copying lib\yaml\__init__.py -> build\lib.win-amd64-2.7\yaml
running build_ext
creating build\temp.win-amd64-2.7
creating build\temp.win-amd64-2.7\Release
checking if libyaml is compilable
error: [Error 2] The system cannot find the file specified
更新
我注意到当我手动激活虚拟环境并执行 "pip install pyyaml" 时,会发生相同的错误。但是当我在常规命令提示符下执行相同的命令时,安装成功。
因此,这似乎是pyyaml和虚拟环境的问题,而不是tox本身的问题。另外,如果我在tox.ini中尝试使用easy_install命令,则可以正常工作,没有任何问题。
[testenv]
install_command = easy_install {opts} {packages}
tox.ini
的[testenv]
下使用passenv = *
会有什么变化吗? - The Compiler