2017-02-23 97 views
0

當試圖安裝cxvopt包的Python,使用Windows點子,我收到以下錯誤信息:CVXOPT安裝失敗,在複雜的類型聲明文件misc.h

misc.h(35): error C2146: syntax error: missing ';' before identifier 'z' 
misc.h(35): error C2061: syntax error: identifier 'z' 
misc.h(36): error C2059: syntax error: '}' 

...等等。

錯誤發生在如下圖所示,在複雜的變量聲明文件misc.h(在base.c參考):

#ifndef NO_ANSI99_COMPLEX 
typedef union { 
    double d; 
    int_t i; 
    double complex z; 
} number; 
#endif 

這並不是我使用另一臺計算機上發生。根據需要安裝了Visual Studio 14.0。

任何看過這個問題的人都可以提出解決方案嗎? (我的第一個想法是包含「complex.h」,但是在cvxopt.h中引用了它,它包含在misc.h之前的base.c中)。

+0

什麼是'int_t'? – Olaf

回答

0

Visual Studio 14.0有一個可憐的ANSI C89編譯器,它甚至不支持the obsolete ISO C99 standard that this code requires。我想你是爲了編譯成功而定義宏NO_ANSI99_COMPLEX;如果定義了這個宏,代碼會跳過C99特定的結構。

我相信這個宏是在成功編譯其他計算機上的代碼時定義的?

0

cvxopt在3.4版以後的python版本的windows上不支持,我無法根據其他答案中列出的原因構建它。我正在使用conda,並且爲python 3.4創建了一個獨立的環境,並使用pip安裝了cvxopt,並且它工作正常,因爲該版本的Python有預構建的二進制文件。我也得到了安裝VS14

Visual Studio的CPP構建工具(在暢達命令提示符以管理員身份運行)

//Setup vcvars using batch file change to whatever path and version of vcvars is correct for you 
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\amd64\vcvars64.bat" 
//setup new environment using python 3.4 
conda create -n py34 python=3.4.5 anaconda 
//switch to new environment 
activate py34 
//install cvxopt 
pip install cvxopt