How to use GLPK with cvxopt in Windows 10?
Asked Answered
C

3

6

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?

Contrabass answered 19/1, 2018 at 19:55 Comment(8)
You will need to follow those steps here which do not mention GLPK-compilation, which itself should be found in GLPKs docs. This is probably trouble and i'm not sure if it's worth it (Linux and Mac builds bring it for free). Keep in mind, that it's not process-based / calling glpk.exe or such, but library-call based (it does not matter whatever binary is in the path; the correct libs need to be available, at least at compile-time!).Arnulfoarny
Wheels for Windows: do not include any of the optional extensions,so you need build from source.Spanner
@Spanner Could you please provide how to build from source with GLPK enabled for python? I searched everwhere, but couldn't find a solution.Contrabass
lfd.uci.edu/~gohlke/pythonlibs/#cvxoptDrome
@denfromufa does installing this wheel enable importing cvxopt.glpk ?Contrabass
According to the website yesDrome
@Contrabass do you still interest about how compile form source?it will take time.Spanner
@Spanner yes. will you provide an answer?Contrabass
C
5

Installing cvxopt with the wheel file found at this link solved problem:

https://www.lfd.uci.edu/~gohlke/pythonlibs/#cvxopt

Many thanks to denfromufa.

Contrabass answered 25/1, 2018 at 11:19 Comment(0)
J
2

Installing numpy+mk from this link: http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy and cvxopt with wheel file found in this link should solved problem: https://www.lfd.uci.edu/~gohlke/pythonlibs/#cvxopt

Judaic answered 27/9, 2018 at 16:15 Comment(0)
H
0

We had to install the following to get cvxopt to work (though we are using it from within cvxpy):

On the OS level: - python3-cvxopt - glpk-utils - libglpk-dev

In Python: - pip install cvxpy - pip install cvxopt

Hudgins answered 18/11, 2019 at 9:47 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.