Ryan Erwin Ryan Erwin - 1 year ago 73
Python Question

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

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':

file is located in
and has been added to the PATH variable.

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

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download