Python CVXOPT安装在文件misc.h中的复杂类型声明失败
尝试在Windows上使用pip安装Python的cxvopt包时,我收到以下错误消息:Python CVXOPT安装在文件misc.h中的复杂类型声明失败,python,c,cvxopt,Python,C,Cvxopt,尝试在Windows上使用pip安装Python的cxvopt包时,我收到以下错误消息: 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中引用)的复杂
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中。)Visual Studio 14.0有一个可怜的ANSI C89编译器,它甚至不支持。我想您应该定义宏
NO\u ANSI99\u COMPLEX
,以使编译成功;如果定义了此宏,代码将跳过C99特定的构造
我相信这个宏是在您在另一台计算机上成功编译代码时定义的?3.4之后的windows for python版本不支持cvxopt,并且由于另一个答案中概述的原因,我无法构建它。我使用的是conda,我为Python3.4创建了一个单独的环境,并使用pip安装了cvxopt,它工作得很好,因为该版本的python有预构建的二进制文件。我还为VS14安装了visual studio cpp构建工具 (在以管理员身份运行的conda命令提示符中)
//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