I'm on Mac OS X El Capitan.
I've installed GLPK via brew install GLPK
I have python installed via Anaconda.
Because I want the GLPK bindings for CVXOPT, I'm installing it manually instead of via condo install
.
I got the installer here: http://cvxopt.org/download/index.html
And once I got the installer I followed the instructions on this page:
http://lecueguillaume.github.io/2016/02/27/cvxopt-glpk-basis-pursuit/
to modify the setup.py file.
I made a few additional changes. First I commented out the environment variables so as to rule out the possibility that it picks them up instead of the variable I put in the file:
#BUILD_GLPK = int(os.environ.get("CVXOPT_BUILD_GLPK",BUILD_GLPK))
#GLPK_LIB_DIR = os.environ.get("CVXOPT_GLPK_LIB_DIR",GLPK_LIB_DIR)
#GLPK_INC_DIR = os.environ.get("CVXOPT_GLPK_INC_DIR",GLPK_INC_DIR)
Next I have these variables set:
- Set to 1 if you are installing the glpk module.
BUILD_GLPK = 1
- Directory containing
libglpk
(used only whenBUILD_GLPK = 1
).GLPK_LIB_DIR = '/usr/local/Cellar/glpk/4.57/lib'
- Directory containing
glpk.h
(used only whenBUILD_GLPK = 1
).GLPK_INC_DIR = '/usr/local/Cellar/glpk/4.57/include'
My brew install gave me gulp 4.57 instead of the one in the tutorial, so I modified those version numbers in the above.
Finally, to make sure it's running, I added this:
if BUILD_GLPK:
print "*** BUILDING GLPK ***"
The if BUILD_GLPK
was already there, I added the print line.
Then I went ahead and ran python setup.py install
Looks great:
*** BUILDING GLPK ***
running install
running bdist_egg
running egg_info
writing cvxopt.egg-info/PKG-INFO
writing top-level names to cvxopt.egg-info/top_level.txt
writing dependency_links to cvxopt.egg-info/dependency_links.txt
reading manifest file 'cvxopt.egg-info/SOURCES.txt'
writing manifest file 'cvxopt.egg-info/SOURCES.txt'
installing library code to build/bdist.macosx-10.6-x86_64/egg
running install_lib
running build_py
running build_ext
sh: line 1: 91286 Segmentation fault: 11 'gcc' --version 2> /dev/null > '/tmp/tmp1Xzj0m'
creating build/bdist.macosx-10.6-x86_64/egg
creating build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/__init__.py -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/amd.so -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/base.so -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/blas.so -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/cholmod.so -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/coneprog.py -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/cvxprog.py -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/glpk.so -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/info.py -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/lapack.so -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/misc.py -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/misc_solvers.so -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/modeling.py -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/msk.py -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/printing.py -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/solvers.py -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
copying build/lib.macosx-10.6-x86_64-2.7/cvxopt/umfpack.so -> build/bdist.macosx-10.6-x86_64/egg/cvxopt
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/__init__.py to __init__.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/coneprog.py to coneprog.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/cvxprog.py to cvxprog.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/info.py to info.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/misc.py to misc.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/modeling.py to modeling.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/msk.py to msk.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/printing.py to printing.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/solvers.py to solvers.pyc
creating stub loader for cvxopt/glpk.so
creating stub loader for cvxopt/base.so
creating stub loader for cvxopt/blas.so
creating stub loader for cvxopt/lapack.so
creating stub loader for cvxopt/umfpack.so
creating stub loader for cvxopt/cholmod.so
creating stub loader for cvxopt/amd.so
creating stub loader for cvxopt/misc_solvers.so
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/glpk.py to glpk.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/base.py to base.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/blas.py to blas.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/lapack.py to lapack.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/umfpack.py to umfpack.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/cholmod.py to cholmod.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/amd.py to amd.pyc
byte-compiling build/bdist.macosx-10.6-x86_64/egg/cvxopt/misc_solvers.py to misc_solvers.pyc
creating build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying cvxopt.egg-info/PKG-INFO -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying cvxopt.egg-info/SOURCES.txt -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying cvxopt.egg-info/dependency_links.txt -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
copying cvxopt.egg-info/top_level.txt -> build/bdist.macosx-10.6-x86_64/egg/EGG-INFO
writing build/bdist.macosx-10.6-x86_64/egg/EGG-INFO/native_libs.txt
zip_safe flag not set; analyzing archive contents...
creating 'dist/cvxopt-1.1.8-py2.7-macosx-10.6-x86_64.egg' and adding 'build/bdist.macosx-10.6-x86_64/egg' to it
removing 'build/bdist.macosx-10.6-x86_64/egg' (and everything under it)
Processing cvxopt-1.1.8-py2.7-macosx-10.6-x86_64.egg
Copying cvxopt-1.1.8-py2.7-macosx-10.6-x86_64.egg to /Users/myUsername/anaconda/lib/python2.7/site-packages
Adding cvxopt 1.1.8 to easy-install.pth file
Yet, when I run it in python:
/Users/myUsername/anaconda/lib/python2.7/site-packages/cvxopt-1.1.8-py2.7-macosx-10.6-x86_64.egg/cvxopt/coneprog.pyc in lp(c, G, h, A, b, solver, primalstart, dualstart, **kwargs)
2805 if solver == 'glpk':
2806 try: from cvxopt import glpk
-> 2807 except ImportError: raise ValueError("invalid option "\
2808 "(solver = 'glpk'): cvxopt.glpk is not installed")
2809 glpk.options = options.get('glpk',{})
ValueError: invalid option (solver = 'glpk'): cvxopt.glpk is not installed
I've tried uninstalling and re-installing several different ways. This one seemed the most promising, but I'm still getting no luck. Any advice?