CVXOPT安装在misc.h文件中的复杂类型声明时失败

2024-07-08 08:53:54 发布

您现在位置:Python中文网/ 问答频道 /正文

在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中引用)的复杂变量声明中,如下所示:

^{pr2}$

这不会发生在我正在使用的另一台计算机上。根据需要,两者都安装了visualstudio14.0。在

有谁见过这个问题,能提出解决办法吗?(我的第一个想法是包含“complex.h”,但这是在cvxopt.h中引用的,它在misc.h之前包含在base.c中。)


Tags: pip消息basewindows错误errormiscidentifier
2条回答

visualstudio14.0有一个可怜的ansic89编译器,它甚至不支持the obsolete ISO C99 standard that this code requires。我想您应该定义宏NO_ANSI99_COMPLEX,以便编译成功;如果定义了这个宏,代码将跳过C99特定的构造。在

我相信这个宏是你在另一台计算机上成功编译代码时定义的?在

我在第三个版本之后就不支持了。我使用的是conda,我为python3.4创建了一个单独的环境,并使用pip安装了cvxopt,它工作得很好,因为有针对该版本python的预构建的二进制文件。我还为VS14安装了visualstudiocpp构建工具

(在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

相关问题 更多 >

    热门问题