Search code examples
python-2.7pytestpyyamltox

tox fails to install pyYaml on windows


My tox.ini file looks like this on 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

But when I do "tox" from command prompt, I'm seeing this error. Why is this? I don't see any error, if I run python setup.py install on command line

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

UPDATE

I did notice that, when I manually activate the virtualenv and do "pip install pyyaml" it fails with the same error. But when I'm in the regular command prompt, not virtualenv, and do the same command, it installs fine.

So this seems like an issue with pyyaml and virtualenv but not tox per se. Also if I try with easy_install command in tox.ini it works w/o any issues.

[testenv]
install_command = easy_install {opts} {packages}

Solution

  • It looks like there are no wheels for the binaries and when PIP downloads PyYAML it tries to build it and cannot. I fixed this for my computer by downloading the source code, building a wheel and then uploading it to my local devpi server. I could then install it using pip inside a virtualenv. I'm using Windows 10, if that matters.

    EDIT Found the issue. This needs to be installed. VC for Python (this is 2.7, but use appropriate) https://www.microsoft.com/en-gb/download/details.aspx?id=44266