Sam
Sam

Reputation: 21

When using Gurobi solver, are solver_io=direct or python options supported with python 3.6?

Here is a toy code that I'm playing with:

from __future__ import division
from pyomo.environ import *
from pyomo.opt import SolverStatus, TerminationCondition
import sys

sys.path.append('/Library/gurobi810/mac64/lib/gurobipy')

model = ConcreteModel()
model.x = Var([1,2], domain=NonNegativeReals)
model.obj = Objective(expr = 2*model.x[1] + 3*model.x[2])
model.constraint1 = Constraint(expr = 3*model.x[1] + 4*model.x[2] >= 1)

opt = SolverFactory('gurobi_direct')
#opt = SolverFactory('gurobi')
#opt = SolverFactory('gurobi', solver_io='python')

rr = opt.solve(model)

The above code works fine, with either solver_io='python' or with 'gurobi_direct' only in a Python 2.7 virtual environment. When I'm working in a Python 3.6 virtual environment, I get the following error:

pyutilib.common._exceptions.ApplicationError: No Python bindings available for <class 'pyomo.solvers.plugins.solvers.gurobi_direct.GurobiDirect'> solver plugin

Does this mean that Pyomo does not support these options for Python 3.6? Any work around?

Upvotes: 2

Views: 581

Answers (1)

Qi Chen
Qi Chen

Reputation: 1718

You need to install the Python bindings for Gurobi with your python 3.6 virtual environment as well (using python setup.py install in the Gurobi bindings)

Upvotes: 1

Related Questions