David Halley
David Halley

Reputation: 457

pyomo cannot locate the 'gurobi' executable

I am having issues with getting pyomo and gurobi to interact in python. I am running an optimization problem where I am using pyomo to build up the optimization problem itself and then gurobi to solve it. I have been digging deep into the issues, but unfortunately I have not succeeded in finding a solution. I came across several observations that confuses me somehow. These are:

I am running python2.7, pyomo6.5 and gurobi9.1

Also, the following is how my bashrc file looks. It is a bit complicated, but I strongly assume that the paths are set correct.

# User specific aliases and functions
export PATH=/usr/local/anaconda27/bin:$PATH
export LD_LIBRARY_PATH=/etc/glad-smail-liberr:$LD_LIBRARY_PATH

#export GUROBI_HOME="/opt/gurobi650/linux64"
export GUROBI_HOME="/usr/local/anaconda27"
export PATH="${PATH}:${GUROBI_HOME}/bin"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:${GUROBI_HOME}/lib"
export GRB_LICENSE_FILE="${GUROBI_HOME}/lib/gurobi.lic"

Below, I have inserted the error-message:

WARNING:pyomo.solvers:Could not locate the 'gurobi' executable, which is required for solver gurobi
failed
Traceback (most recent call last):
File "scripts/solve_network.py", line 179, in <module>
    solve_model(network)
  File "scripts/solve_network.py", line 106, in solve_model
    network.lopf(network.snapshots,solver_name=solver_name,solver_io=solver_io,solver_options=solver_options,extra_functionality=extra_functionality,keep_files=network.opf_keep_files,formulation=options['formulation'])
  File "/usr/local/anaconda27/lib/python2.7/site-packages/pypsa-0.15.0-py2.7.egg/pypsa/opf.py", line 1673, in network_lopf
    extra_postprocessing=extra_postprocessing)
  File "/usr/local/anaconda27/lib/python2.7/site-packages/pypsa-0.15.0-py2.7.egg/pypsa/opf.py", line 1580, in network_lopf_solve
    network.results = network.opt.solve(*args, suffixes=["dual"], keepfiles=keep_files, logfile=solver_logfile, options=solver_options)
  File "/usr/local/anaconda27/lib/python2.7/site-packages/Pyomo-5.6-py2.7-linux-x86_64.egg/pyomo/opt/base/solvers.py", line 512, in solve
    self.available(exception_flag=True)
  File "/usr/local/anaconda27/lib/python2.7/site-packages/Pyomo-5.6-py2.7-linux-x86_64.egg/pyomo/solvers/plugins/solvers/GUROBI.py", line 155, in available
    val = ILMLicensedSystemCallSolver.available(self, exception_flag)
  File "/usr/local/anaconda27/lib/python2.7/site-packages/Pyomo-5.6-py2.7-linux-x86_64.egg/pyomo/opt/solver/ilmcmd.py", line 36, in available
    if not pyomo.opt.solver.shellcmd.SystemCallSolver.available(self, exception_flag):
  File "/usr/local/anaconda27/lib/python2.7/site-packages/Pyomo-5.6-py2.7-linux-x86_64.egg/pyomo/opt/solver/shellcmd.py", line 126, in available
    raise ApplicationError(msg % self.name)
pyutilib.common._exceptions.ApplicationError: No executable found for solver 'gurobi'

This error-message clearly states that pyomo cannot locate the gurobi isntallation. But, I am able to use gurobi in other optimisation problems where pyomo is not used.

I really hope that someone can get me going.

Upvotes: 0

Views: 1340

Answers (1)

mattmilten
mattmilten

Reputation: 6726

Your GUROBI_HOME environment variable is incorrect. The correct path is commented out in the line above:

export GUROBI_HOME="/opt/gurobi650/linux64"

You should also update to Python 3 - version 2 is deprecated and not supported anymore.

Upvotes: 0

Related Questions