Search code examples
pythonpython-3.xglpkpyomo

Pyomo - GLPK - Error


I've installed Pyomo (v 4.4.1) and GLPK for Windows (v 4.55). I've added the directory for the glpsol.exe to the PATH variable and I can use the command glpsol --help successfully from any directory in the command prompt. According to Pyomo's blog, this should indicate a successful installation of GLPK as far as Pyomo's concerned. However, when I try the following example:

from pyomo.opt import SolverFactory
opt = SolverFactory("glpk")

I get the error:

ERROR:pyomo.opt:Failed to create solver with name 'glpk':
The asl solver plugin was not registered as a valid solver plugin - cannot construct solver plugin with IO mode=nl

ERROR: "[base]\site-packages\pyomo\opt\base\solvers.py", 200, __solver_call__
Failed to create solver with name 'glpk':

The glpsol.exe file is located in C:\glpk and has been added to the PATH variable.

I cannot seem to get this going and any help will be greatly appreciated!


Solution

  • You need to import pyomo.environ before you call the SolverFactory.