Pyomo 在 Docker 机器上找不到 GLPK 求解器

Rya*_*ene 5 glpk docker pyomo

我有一台运行 Linux 的 Docker 机器。我正在将 Pyomo 与 GLPK 求解器一起使用。我从 Docker 映像的 shell 命令行安装了 GLPK,使用apt-get install glpk-utils

我所有的代码都保存在子文件夹下 /code

我可以看到glpsol安装在路径下:/usr/bin

我可以看到这/usr/bin是 PATH 环境变量下的路径。

我有相关的进口如下:

from pyomo.environ import *
from pyomo.opt import SolverFactory
Run Code Online (Sandbox Code Playgroud)

当我运行时opt = SolverFactory("glpk"),出现以下错误:

Attempting to use an unavailable solver.

The SolverFactory was unable to create the solver "glpk"
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 "solve").

The original solver was created with the following parameters:
    type: glpk
    _args: ()
    options: {}
Run Code Online (Sandbox Code Playgroud)

我不确定这是否与 Docker 相关,或者我是否应该为apt-get.

我已经使用了所有最新版本的所有内容。

真的很感激这方面的任何帮助。