pyomo无法定位'gurobi'可执行文件

0 人关注

我在让pyomo和gurobi在python中互动方面遇到了问题。我正在运行一个优化问题,我使用pyomo来建立优化问题本身,然后用gurobi来解决它。我一直在深入研究这些问题,但不幸的是,我没有成功地找到解决方案。我遇到了几个令我困惑的现象。这些是。

  • I am able to solve one of those simple optimization problems that gurobi provides from their websites. With this I believe that gurobi is installed.
  • I can import gurobi into python, but I cannot enter the gurobi shell (gurobi.sh) from the bash. I get an (command not found - error). On the other hand, I was able to use the grbgetkey command to add a license. This indicates that gurobi is either not installed or the path is not set correctly, but I am able to import it into python.
  • 我正在运行Python2.7、Pyomo6.5和Gurobi9.1。

    另外,下面是我的bashrc文件的样子。这有点复杂,但我强烈认为路径设置是正确的。

    # 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"
    

    下面,我插入了错误信息。

    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'
    

    这个错误信息明确指出,Pyomo无法找到gurobi的安装位置。但是,我能够在其他不使用pyomo的优化问题中使用gurobi。

    我真的希望有人能让我前进。