I have a pyomo model that I can solve using the GLPK solver by just using the code:

solver = pyo.SolverFactory('glpk')
solver.options['mipgap'] = 0.02
solution = solver.solve(model, tee=True)

Now I have installed the academic version of Gurobi on my computer. However I can't use Gurobi when having the code:

solver = pyo.SolverFactory('gurobi', solver_io="python")
solver.options['mipgap'] = 0.02
solution = solver.solve(model, tee=True)

I get the error message:

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

Now I found this discussion on Stackoverflow Pyomo can't use Gurobi solver I did what the accepted answer advices. I used the windows cmd and navigated to my installation path of Gurobi. I tried two different folders

  • C:\Gurobi\win64\
  • C:\Gurobi\

and I use the suggested command

python setup.py install

However, I get an error message in the cmd of Windows telling that the command 'python' can't be found or is wrong. Do you know what I have to do in order to use Gurobi with Pyomo in Python?

  • $\begingroup$ Shouldn't it be py3 setup.py install or py -3 setup.py install on Windows? $\endgroup$
    – joni
    Commented Feb 24, 2021 at 11:29

1 Answer 1


The mentioned link is about using gurobipy (gurobi's interface for python) to model your problem and solve it using gurobi. If you want to model the problem using Pyomo and use gurobi as a solver, you need to add the gurobi solver to the system's path. For that do the followings:

  1. In Windows search for Edit the system environment variables (I am not familiar with Mac OS).
  2. Open Environment Variables
  3. In the System variables window click on Path and add the folder that includes your gurobi.exe

then use the following in your code:

solver = pyo.SolverFactory('gurobi')
solver.options['MIPGap'] = 0.02
solution = solver.solve(model, tee=True)
  • $\begingroup$ Thanks Oguz for your comment. Unfortunately, I can't find the gurobi.exe file altough Gurobi has been installed and there is a folder that contains several subfolders $\endgroup$
    – PeterBe
    Commented Feb 25, 2021 at 9:43
  • $\begingroup$ Update: I just adjusted the path variables to the correct Gurobi folder (however, I still can't find any gurobi.exe file). Now when I use your suggested code I get the error message: "ApplicationError: No executable found for solver 'gurobi'" $\endgroup$
    – PeterBe
    Commented Feb 25, 2021 at 9:49
  • $\begingroup$ Any idea why this problem occurs and what I can do? I'd appreciate every further comment $\endgroup$
    – PeterBe
    Commented Feb 26, 2021 at 8:06
  • $\begingroup$ Thanks for your comments and answers. Do you have any idea why Python/Pyomo still can't find the Gurobi solver (see my last update comment)? I'd appreciate any further comments from you. $\endgroup$
    – PeterBe
    Commented Mar 1, 2021 at 9:08
  • 1
    $\begingroup$ Thanks Oguz. Now basically it works as intended (I think I just had to restart my laptop to apply all the changes). I really appreciate your great help. I have upvoted and accepted your answer. $\endgroup$
    – PeterBe
    Commented Mar 1, 2021 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.