Visual C++ for python failed with exit status 2 when installing divisi2

Question:

I am using Python 2.7 on Windows 8.1 46 bit.

I want to install divisi2

I have installed NumPy and SciPy which are the pre-requisites for divisi2 already. I have installed Visual C++ for python 9.0.

Whenever I issue the pip install divisi2 command I get the following error in the console.


    svdlib/svdwrapper.c(89) : error C2059: syntax error : '{'
    svdlib/svdwrapper.c(90) : error C2275: 'PyObject' : illegal use of this type as an expression c:python27includeobject.h(108) : see declaration of 'PyObject'
    svdlib/svdwrapper.c(90) : error C2065: 'arr' : undeclared identifier
    svdlib/svdwrapper.c(90) : error C2065: 'type' : undeclared identifier
    svdlib/svdwrapper.c(90) : warning C4047: 'function' : 'PyArray_Descr *' differs in levels of indirection from 'int'
    svdlib/svdwrapper.c(90) : warning C4024: 'function through pointer' : different types for formal and actual parameter 2
    svdlib/svdwrapper.c(91) : error C2065: 'dim' : undeclared identifier
    svdlib/svdwrapper.c(91) : warning C4047: 'function' : 'npy_intp *' differs in levels of indirection from 'int'
    svdlib/svdwrapper.c(91) : warning C4024: 'function through pointer' : different types for formal and actual parameter 4
    svdlib/svdwrapper.c(91) : error C2065: 'strides' : undeclared identifier
    svdlib/svdwrapper.c(91): warning C4047: 'function' : 'npy_intp *' differs in levels of indirection from 'int'
    svdlib/svdwrapper.c(91): warning C4024: 'function through pointer': different types for formal and actual parameter 5
    svdlib/svdwrapper.c(95) : error C2065: 'arr' : undeclared identifier
    svdlib/svdwrapper.c(96): error C2065: 'arr': undeclared identifier
    svdlib/svdwrapper.c(96): warning C4047: 'return': 'int *' differs in levels of indirection from 'int'
    svdlib/svdwrapper.c(100) : error C2143: syntax error : missing '{' before '*'
    svdlib/svdwrapper.c(102) : warning C4133: 'initializing' : incompatible types - from 'int *' to 'PyObject *'
    svdlib/svdwrapper.c(114) : warning C4133: 'return' : incompatible types - from 'PyObject *' to 'int *'
    error: command 'C:\Users\i054564\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\VC\Bin\cl.exe' failed with exit status 2

    ----------------------------------------
Command "c:python27python.exe -u -c "import setuptools, tokenize;__file__='c:
users\i054564\appdata\local\temp\pip-build-0aufqt\divisi2\setup.py';exec
(compile(getattr(tokenize, 'open', open)(__file__).read().replace('rn', 'n'),
    __file__, 'exec'))" install --record c:usersi054564appdatalocaltemppip-5dxl7g-recordinstall-record.txt --single-version-externally-managed --compile" failed with error code 1 in c:usersi054564appdatalocaltemppip-build-0aufqtdivisi2
Asked By: saurav

||

Answers:

I finally solved this problem after getting this hint from a colleague i.e. to use

https://github.com/develersrl/gccwinbinaries.

This will install the requisites and then you can install divisi2.

Answered By: saurav

Came across this issue when installing pycocotools on windows 10. Python 2.7 is incompatible or does not support Visual C++ 14 that is required to compile C99 code.
This is the reason for the compiling errors (C2065,C4047 etc).

You need to,

  1. Install Visual Studio 2015 build tools (this will install C++ 14 compiler).
  2. Install a new newer version of Python (3.6 recommended)

More about Windows Compilers for Python here.

enter image description here

Answered By: rakidedigama

Both the above methods work nicely.
This one is a bit easier though.
Install Visual C++ 2015 Build Tools from https://go.microsoft.com/fwlink/?LinkId=691126 with default selection.

Answered By: ASHu2
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.