Here's what I'm using now for testing (on Windows 10 with Python 2.7)
import os
import pyomo.opt
MINLP_SOLVER_NAME = 'bonmin'
MINLP_SOLVER_PATH = os.path.join("C:\\", "Solvers", "bonmin.exe")
print(MINLP_SOLVER_PATH)
print(os.path.exists(MINLP_SOLVER_PATH))
with pyomo.opt.SolverFactory(MINLP_SOLVER_NAME, executable = MINLP_SOLVER_PATH) as opt:
print(opt.executable())
This code results in the following error:
C:\Solvers\bonmin.exe
True
Traceback (most recent call last):
File "D:\\test.py", line 10, in <module>
print(opt.executable())
File "D:\Python27\lib\site-packages\pyomo\opt\base\solvers.py", line 139, in __getattr__
self._solver_error(attr)
File "D:\Python27\lib\site-packages\pyomo\opt\base\solvers.py", line 153, in _solver_error
+ "\n\toptions: %s" % ( self.options, ) )
RuntimeError: Attempting to use an unavailable solver.
The SolverFactory was unable to create the solver "bonmin"
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 "executable").
The original solver was created with the following parameters:
executable: C:\Solvers\bonmin.exe
type: bonmin
_args: ()
options: {}