0

Quite new to Python and struggling to get glpk to work in a model using pyomo.

I'm trying to use the GLPK solver with Pyomo. I have a working model that is tested to work, but keep getting an error saying GLPK can't be found.

I'm on a Mac (MacOS Big Sur 11.6), installed Anaconda and created a virtual environment using Python 3.7, as I could not load all of the packages I need in 3.10. glpk is installed into the environment, but when I launch a Jupyter notebook and run a model that is tested to work, I get the following error message.

"WARNING: Could not locate the 'glpsol' executable, which is required for solver 'glpk'"

The same issue is found here, but I was not able to employ the same solution on my Mac.

Appreciate any advice, very new to Python and would love to get this set up so I can get going. Thanks in advance.

prg1991
  • 1
  • 1
  • This happpens cause the solver `glpsol` is not added to path. In order let `pyomo` to find it, you need whether to add the `glpsol` directory to PATH, or to provide the directory directly in pyomo with `solver = pyo.SolverFactory('glpk', executable='path/to/solver/directory')` – pybegginer Feb 21 '22 at 15:17
  • Thank you. I was able to solve the issue by uninstalling glpk in terminal and reinstalling it directly from terminal instead of anaconda using conda remove glpk conda install glpk --channel conda-forge Launching a jupyter notebook directly from terminal then worked with glpk installed in the proper path. – prg1991 Feb 21 '22 at 20:17

0 Answers0