I use os x 10.11, anaconda 1.3.1, python 3.5, glpk 4.60, pyomo 5.0.1, spyder 3.0.2. If i run a scrip which uses pyomo to call glpk i get the following warning and error:
WARNING:pyomo.solvers:Could not locate the 'glpsol' executable, which is required for solver 'glpk'
ApplicationError: No executable found for solver 'glpk'
If i start the same script via the terminal or a jupyter notebook it runs without a problem.
I installed glpk using:
conda install -c conda-forge glpk=4.60
How do i get glpk working within the spyder environement?
If i run
which glpsol
i get
/Users/myusername/anaconda/bin/glpsol
but adding the directory into the PYTHONPATH manager within Spyder does not change anything.
Any help is highly appreciated. Thanks
Pyomo's GLPK interface works by launching
glpsolas a separate process. It finds theglpsolexecutable by searching thePATHenvironment variable. You need to make sure that the path toglpsol(in your case/Users/myusername/anaconda/bin/) is in thePATHenvironment variable for the spyder environment. You can do this in a number of ways:Tools-Current user environment variablesin the spyder IDE.~/.bashrcfor BASH,~/.cshrcfor CSH/TCSH) to set thePATHenvironment variable there.[within Spyder] you can specify either a couple lines of python code or a small script that adds the directory to the IPython console PATH through the spyder preferences (
Tools-Preferences-IPython console-Startuptab. You would want something like:Note:
PATHandPYTHONPATHare not the same:PATHis the executable search path.PYTHONPATHis the search path that Python uses to find importable modules.