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
glpsol
as a separate process. It finds theglpsol
executable by searching thePATH
environment variable. You need to make sure that the path toglpsol
(in your case/Users/myusername/anaconda/bin/
) is in thePATH
environment variable for the spyder environment. You can do this in a number of ways:Tools
-Current user environment variables
in the spyder IDE.~/.bashrc
for BASH,~/.cshrc
for CSH/TCSH) to set thePATH
environment 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
-Startup
tab. You would want something like:Note:
PATH
andPYTHONPATH
are not the same:PATH
is the executable search path.PYTHONPATH
is the search path that Python uses to find importable modules.