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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/39771592/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 22:41:20  来源:igfitidea点击:

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

pythonpip

提问by saurav

i am using Python 2.7 on Windows 8.1 46 bit.

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

I want to install divisi2 https://pypi.python.org/pypi/Divisi2/2.2.5

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

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

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

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

每当我发出 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\

cheers,

干杯,

Saurav

索拉夫

采纳答案by saurav

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

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

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

https://github.com/develersrl/gccwinbinaries

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

这将安装必备软件,然后您可以安装 divisi2。

回答by rakidedigama

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).

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

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)
  1. 安装 Visual Studio 2015 构建工具(这将安装 C++ 14 编译器)。
  2. 安装新版本的 Python(推荐 3.6)

More about Windows Compilers for Python here.

有关 Python 的 Windows 编译器的更多信息,请访问此处

enter image description here

在此处输入图片说明

回答by ASHu2

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=691126with default selection.

以上两种方法都很好用。
不过这个要容易一些。
https://go.microsoft.com/fwlink/?LinkId=691126使用默认选择安装 Visual C++ 2015 Build Tools 。