How to use GLPK with cvxopt in Windows 10?

320 views
Skip to first unread message

James Zack

unread,
Jan 19, 2018, 6:37:16 PM1/19/18
to CVXOPT
Hi,

I use 64 bit Windows 10. I downloaded glpk-4.64 for Windows. I unzipped the file to my documents. I added the w64 path in this folder to Windows' environment variables. I check if the glpk works in command line by executing this:


C:\Users\userz>glpsol
GLPSOL: GLPK LP/MIP Solver, v4.64
No input problem file specified; try glpsol --help


So I think glpk is installed properly.

Then I install cvxopt using this in command line:


python -m pip install cvxopt


Then it installs cvxopt.

When I do:


import cvxopt.glpk


I get this error:


import cvxopt.glpk
ImportError: No module named glpk


So, how do I fix this?


Best Regards

Dima Pasechnik

unread,
Jan 20, 2018, 5:11:26 AM1/20/18
to CVXOPT
You need to build cvxopt's glpk Python extension. The latter is a wrapper around glpk DLL, which, I guess, is included in the glpk binary distribution.
Probably this means that you need to build cvxopt from source.

James Zack

unread,
Jan 21, 2018, 4:30:51 AM1/21/18
to CVXOPT
Hi,

Do you know how to build cvxopt's glpk Python extension under Wİndows 10? Could you please help?

Thanks
Best Regards

Dima Pasechnik

unread,
Jan 21, 2018, 5:28:43 AM1/21/18
to CVXOPT


On Sunday, January 21, 2018 at 9:30:51 AM UTC, James Zack wrote:
Do you know how to build cvxopt's glpk Python extension under Wİndows 10? Could you please help?

Lines 41-47 of setup.py have 3 parameters dealing with glpk

You need to set the 1st one to 1, and the 2nd and the 3rd to specify the library location and its headers.
(I don't have a Windows machine to try this, though)

----------------

Another, I suppose, much easier, way around might be to use Anaconda;
they provide cvxopt and glpk, and as far as I can see they build
the glpk extension for cvxopt:

HTH
Dima

Martin

unread,
Jan 21, 2018, 1:13:53 PM1/21/18
to CVXOPT
The conda-forge channel only contains CVXOPT for macOS and Linux. 

You could try the (unofficial) wheels provided here: https://www.lfd.uci.edu/~gohlke/pythonlibs/#cvxopt
Reply all
Reply to author
Forward
0 new messages