安装divisi2时,Visual C ++ for python失败,退出状态为2

时间:2016-09-29 13:24:37

标签: python pip

我在Windows 8.1 46位上使用Python 2.7。

我想安装divisi2 https://pypi.python.org/pypi/Divisi2/2.2.5

我已经安装了NumPy和SciPy,这些已经是divisi2的先决条件。我已经为python 9.0安装了Visual C ++。

每当我发出pip install divisi2命令时,我都会在控制台中收到以下错误。

     svdlib/svdwrapper.c(89) : error C2059: syntax error : '{'
    svdlib/svdwrapper.c(90) : error C2275: 'PyObject' : illegal use of this type
 as an expression
            c:\python27\include\object.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 *' diff
ers in levels of indirection from 'int'
    svdlib/svdwrapper.c(90) : warning C4024: 'function through pointer' : differ
ent 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 i
n levels of indirection from 'int'
    svdlib/svdwrapper.c(91) : warning C4024: 'function through pointer' : differ
ent 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 i
n levels of indirection from 'int'
    svdlib/svdwrapper.c(91) : warning C4024: 'function through pointer' : differ
ent 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 level
s of indirection from 'int'
    svdlib/svdwrapper.c(100) : error C2143: syntax error : missing '{' before '*
'
    svdlib/svdwrapper.c(102) : warning C4133: 'initializing' : incompatible type
s - from 'int *' to 'PyObject *'
    svdlib/svdwrapper.c(114) : warning C4133: 'return' : incompatible types - fr
om 'PyObject *' to 'int *'
    error: command 'C:\\Users\\i054564\\AppData\\Local\\Programs\\Common\\Micros
oft\\Visual C++ for Python\\9.0\\VC\\Bin\\cl.exe' failed with exit status 2

    ----------------------------------------
Command "c:\python27\python.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('\r\n', '\n'),
 __file__, 'exec'))" install --record c:\users\i054564\appdata\local\temp\pip-5d
xl7g-record\install-record.txt --single-version-externally-managed --compile" fa
iled with error code 1 in c:\users\i054564\appdata\local\temp\pip-build-0aufqt\d
ivisi2\

欢呼声,

Saurav

3 个答案:

答案 0 :(得分:3)

在Windows 10上安装pycocotools时遇到此问题。Python2.7不兼容或不支持编译C99代码所需的Visual C ++ 14。 这就是编译错误(C2065,C4047等)的原因。

您需要

  1. 安装Visual Studio 2015生成工具(这将安装C ++ 14编译器)。
  2. 安装新版本的Python(建议使用3.6)

有关适用于Python here的Windows编译器的更多信息。

enter image description here

答案 1 :(得分:2)

我从同事那里得到这个提示后终于解决了这个问题,即使用

https://github.com/develersrl/gccwinbinaries

这将安装必需品,然后您可以安装divisi2。

答案 2 :(得分:0)

以上两种方法都很好用。
不过,这有点容易。
使用默认选择从https://go.microsoft.com/fwlink/?LinkId=691126安装Visual C ++ 2015生成工具。

相关问题