Install cvxopt on 64bit Anaconda

Overview

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.

Assumed environment

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. 84CEE4CD-2BB7-40D7-B2EA-4A2596B8E1A2.png

Dependent library preparation

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.

Compiling CVXOPT

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)

Creating libpython27.a and libmsvcr90.a

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

Source code modification

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.

Compile and install

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

Install cvxopt on 64bit Anaconda
Install Anaconda on Windows 10
Install cvxpy on windows, Anaconda
Install module on Anaconda (Mac)
Install anaconda on Mac → Add Library
Install python2.7 on windows 32bit environment
Install Python 3.7 Anaconda on MAC, but Python 2
Install PyStan on Windows without Anaconda
Install opencv on Mac using Anaconda Navigator
Theano on Anaconda
Install 64-bit OS (bate) on Raspberry Pi
Install CVXOPT, NumPy, SciPy on Travis CI
Install docker-compose on 64-bit Raspberry Pi OS
Install ubuntu on 32bit UEFI Ultra Notebook
Install anaconda on a new Mac anyway
Personal Note Package to install on Anaconda
Install OpenCV 4.0 and Python 3.7 on Windows 10 with Anaconda
[Python] How to install OpenCV on Anaconda [Windows]
Install Ubuntu 20.04 LTS (Server) 64bit version on RaspberryPi3B +
How to install / verify graphviz on anaconda / windows10
Install mecab on Marvericks
Install Tensorflow on Mac
Install TensorFlow on Ubuntu
Install python on WSL
Install Faiss on CentOS 7
Install pyenv on mac
Install pip on Mavericks
Install Python on Pidora.
Install mongodb on termux
Install Scrapy on python3
Install docker on Fedora31
Install numba on CentOS 7.2
Install Ansible on Mac
Install Python on Mac
Install Python 3 on Mac
Install Plone (4.3.6) on MacOSX (10.10.3)
Install PySide2 on Ubuntu
Install Python3.4 on CentOS 6.6
I can't install Anaconda!
Install gensim on Marvericks
Install JModelica on Ubuntu
Anaconda on Windows Terminal
Install numpy on Marvericks
Install python on windows
Install enebular-agent on Chromebook
Install pycuda on Windows10
Install mecab-python on CentOS
Install Python 2.7.3 on CentOS 5.4
Install aws-cli on MacPorts
Install pygraphviz on Windows 10
Install Docker on AWS
Install Python 3.3 on Ubuntu 12.04
Install Chainer 1.5.0 on Windows
Install Python 3.4 on Mac
Install Caffe on Mac
Install Theano on Ubuntu 12.04
Install pyenv on OSX
Install mecab on mac
Install awscli on centos7
Install angr on Ubuntu 18.04
Install Chainer on CentOS 6.7