0

Hi I wrote a simple script on Jupyter notebook to model a problem and then use pyomo's SolverFactory as follows:

from pyomo.opt import SolverFactory
opt = SolverFactory('ipopt')
result = opt.solve(model)

The notebook version cannot run because ipopt cannot be found but when I use command line it runs. Does this have something to do with jupyter notebbok? I prefer to use jupyter notebook if possible since it is interactive. Thank you in advance.

Orion T
  • 13
  • 4

1 Answers1

1

It seems like this is likely because of the differences in sys.path between Jupyter and the command line - see sys.path different in Jupyter and Python - how to import own modules in Jupyter?.

To resolve it, either make the changes recommended there or manually specify the path to the solver executable:

opt = SolverFactory("ipopt", executable="/your_path/to_solver/ipopt")

executable can be either an absolute or relative path.

Dan McCabe
  • 188
  • 1
  • 3
  • 11
  • I tried to indicate my binary location but I still get a similar error as follows: RuntimeError: Attempting to use an unavailable solver. The SolverFactory was unable to create the solver "ipopt" and returned an UnknownSolver object. This error is raised at the point where the UnknownSolver object was used as if it were valid (by calling method "solve"). – Orion T Dec 16 '17 at 01:53