I had a lot of trouble trying to install cvxopt on the 64-bit version of Anaconda on Windows, so I will summarize the work contents.
The cvxopt documentation describes how to install it on Windows (http://cvxopt.org/install/index.html#building-cvxopt-for-windows). However, please note that it seems that it is supposed to be a 32-bit version of Python, and it cannot be installed smoothly according to the document. This article summarizes the changes that need to be made in line with this document.
It is assumed that these are already installed.
In addition, the subsequent work shall be performed in a dedicated directory. For example, if you want to do it in D: \ glpk
, you can open the command prompt by doing the following.
This can be done according to Documentation.
BLAS Download the BLAS source file. Then, execute the following command from the command prompt.
$ tar -xvf blas.tgz
$ cd BLAS-3.5.0
$ sed 's/_LINUX/_WIN/' make.inc -i
$ make && cp blas_WIN.a ../libblas.a
$ cd ..
However, the directory name on the second line changes depending on the version of the acquired BLAS source file, so replace it as appropriate.
LAPACK Download LAPACK source files. Then, execute the following command from the command prompt.
$ tar -xvf lapack-3.5.0.tgz
$ cd lapack-3.5.0
$ cp make.inc.example make.inc
$ make lapacklib && cp liblapack.a ..
$ cd ..
If you are told that libquadmath-0.dll
is missing, download it from here andMinGW / bin Place it in
(it seems to be C: \ MinGW \ bin
by default) and then execute the above command.
From here is the production. Download CVXOPT source file. Then, execute the following command from the command prompt. The file name and folder name change depending on the version, so read them as appropriate.
$ tar -xvf cvxopt-1.1.8.tar.gz
$ cd cvxopt-1.1.8/src
Open setup.py
and
--Changed the initialization of the BLAS_LIB variable around line 12 to BLAS_LIB = ['blas','gfortran']
--Changed the initialization of the BLAS_LIB_DIR variable around the 9th line to BLAS_LIB_DIR ='.'
Next, edit the cygwinccompiler
module of the distutils
package. If Anaconda is located in c: \ Anaconda
, open c: \ Anaconda \ Lib \ distutils \ cygwinccompiler.py
. If there is a string -mno-cygwin
in this file, delete it. (Not in my environment)
The Linux static libraries libpython27.a
and libmsvcr90.a
, which are required for the later processing, are not prepared by default, so they are converted from the libraries for Windows.
First, install the conversion tool.
$ mingw-get install pexports
Next, copy python27.dll
and msvcr90.dll
in the Anaconda directory (eg c: \ Anaconda
) to the directory where cvxopt's setup.py is located.
To create libpython27.a
, execute the following command.
$ pexports python27.dll > python27.def
$ dlltool --dllname python27.dll --def python27.def --output-lib libpython27.a
Creating libmsvcr90.a
is a bit more complicated. First,
$ pexports msvcr90.dll > msvcr90.def
Execute and open the resulting msvcr90.def
with a text editor. And it is near the 304th to 314th lines,
--Change the line _decode_pointer
to; _decode_pointer
--Change the line _encode_pointer
to; _encode_pointer
Correct. afterwards,
dlltool --dllname msvcr90.dll --def msvcr90.def --output-lib libmsvcr90.a
Is executed. Copy the resulting libpython27.a
and libmsvcr90.a
to the Anaconda libs
folder as well.
At that time, if there is python27.lib
in the libs
directory, change it to python27.lib_
.
An error will occur if the original source code is used, so the following file needs to be modified.
src/C/cholmod.c Near the 31st line
cholmod.c
/* defined in pyconfig.h */
#if (SIZEOF_INT < SIZEOF_LONG)
#define CHOL(name) cholmod_l_ ## name
#else
#define CHOL(name) cholmod_ ## name
#endif
To
cholmod.c
/* defined in pyconfig.h */
// #if (SIZEOF_INT < SIZEOF_LONG)
#define CHOL(name) cholmod_l_ ## name
// #else
// #define CHOL(name) cholmod_ ## name
// #endif
Corrected to.
src/C/SuiteSparse/SuiteSparse_config/SuiteSparse_config.h Delete the following code near line 155.
SuiteSparse_config.h
#ifndef NTIMER
#ifdef _POSIX_C_SOURCE
#if _POSIX_C_SOURCE >= 199309L
#define SUITESPARSE_TIMER_ENABLED
#endif
#endif
#endif
src/C/amd.c Near line 27,
amd.c
#if (SIZEOF_INT < SIZEOF_LONG)
#define amd_order amd_l_order
#define amd_defaults amd_l_defaults
#endif
To
amd.c
//#if (SIZEOF_INT < SIZEOF_LONG)
#define amd_order amd_l_order
#define amd_defaults amd_l_defaults
//#endif
Corrected to.
At this point, you can finally compile with the following command.
$ python setup.py build --compiler=mingw32
To install, create distutils.cfg
in Lib / distutils
of Anaconda and enter the following contents.
distutils.cfg
[build]
compiler=mingw32
Then install it.
$ python setup.py install
Recommended Posts