在 Julia 中构建 CPLEX 失败

Building CPLEX fails in Julia

我正在尝试在计算机集群上的 Julia 中安装 CPLEX。当我执行 Pkg.build("CPLEX") 时出现以下错误。看来我没有走对路。我知道如何在我的本地计算机上修复它,但谁能告诉我如何在计算机集群上修复它?还是其他问题?

供您参考,

CPLEX 版本:12.10-GCCcore-8.3.0, 朱莉娅版本:1.7.1.

非常感谢。

宏宇

The versions of CPLEX supported by CPLEX.jl are:

* 12.10
* 20.1

You must download and install one of these versions separately.

You should set the `CPLEX_STUDIO_BINARIES` environment variable to point to
the install location then try again. For example (updating the path to the
correct location):


ENV["CPLEX_STUDIO_BINARIES"] = "/opt/CPLEX_Studio201/cplex/bin/x86-64_linux/"
import Pkg
Pkg.add("CPLEX")
Pkg.build("CPLEX")


See the CPLEX.jl README at https://github.com/jump-dev/CPLEX.jl for further
instructions.

Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:33
 [2] try_local_installation()
   @ Main ~/.julia/packages/CPLEX/88lum/deps/build.jl:132
 [3] top-level scope
   @ ~/.julia/packages/CPLEX/88lum/deps/build.jl:150
 [4] include(fname::String)
   @ Base.MainInclude ./client.jl:451
 [5] top-level scope
   @ none:5
in expression starting at /home/hongyuzh/.julia/packages/CPLEX/88lum/deps/build.jl:143
Stacktrace:
  [1] pkgerror(msg::String)
    @ Pkg.Types /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/Types.jl:68
  [2] (::Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec})()
    @ Pkg.Operations /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:962
  [3] withenv(::Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, ::Pair{String, String}, ::Vararg{Pair{String}})
    @ Base ./env.jl:172
  [4] (::Pkg.Operations.var"#99#103"{String, Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec})()
    @ Pkg.Operations /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1506
  [5] with_temp_env(fn::Pkg.Operations.var"#99#103"{String, Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.PackageSpec}, temp_env::String)
    @ Pkg.Operations /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1390
  [6] (::Pkg.Operations.var"#98#102"{Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String})(tmp::String)
    @ Pkg.Operations /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1469
  [7] mktempdir(fn::Pkg.Operations.var"#98#102"{Bool, Bool, Bool, Pkg.Operations.var"#62#67"{Bool, Pkg.Types.Context, String, Pkg.Types.PackageSpec}, Pkg.Types.Context, Pkg.Types.PackageSpec, String, Pkg.Types.Project, String}, parent::String; prefix::String)
    @ Base.Filesystem ./file.jl:750
  [8] mktempdir(fn::Function, parent::String) (repeats 2 times)
    @ Base.Filesystem ./file.jl:748
  [9] sandbox(fn::Function, ctx::Pkg.Types.Context, target::Pkg.Types.PackageSpec, target_path::String, sandbox_path::String, sandbox_project_override::Pkg.Types.Project; force_latest_compatible_version::Bool, allow_earlier_backwards_compatible_versions::Bool, allow_reresolve::Bool)
    @ Pkg.Operations /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1435
 [10] sandbox(fn::Function, ctx::Pkg.Types.Context, target::Pkg.Types.PackageSpec, target_path::String, sandbox_path::String, sandbox_project_override::Pkg.Types.Project)
    @ Pkg.Operations /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:1432
 [11] build_versions(ctx::Pkg.Types.Context, uuids::Set{Base.UUID}; verbose::Bool)
    @ Pkg.Operations /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:943
 [12] build(ctx::Pkg.Types.Context, uuids::Set{Base.UUID}, verbose::Bool)
    @ Pkg.Operations /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/Operations.jl:822
 [13] build(ctx::Pkg.Types.Context, pkgs::Vector{Pkg.Types.PackageSpec}; verbose::Bool, kwargs::Base.Pairs{Symbol, Base.TTY, Tuple{Symbol}, NamedTuple{(:io,), Tuple{Base.TTY}}})
    @ Pkg.API /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/API.jl:992
 [14] build(pkgs::Vector{Pkg.Types.PackageSpec}; io::Base.TTY, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
    @ Pkg.API /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/API.jl:149
 [15] build(pkgs::Vector{Pkg.Types.PackageSpec})
    @ Pkg.API /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/API.jl:144
 [16] #build#99
    @ /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/API.jl:142 [inlined]
 [17] build
    @ /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/API.jl:142 [inlined]
 [18] #build#98
    @ /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/API.jl:141 [inlined]
 [19] build(pkg::String)
    @ Pkg.API /share/apps/Julia/1.7.1-linux-x86_64/share/julia/stdlib/v1.7/Pkg/src/API.jl:141
 [20] top-level scope
    @ REPL[138]:1

(在评论讨论中找到的解决方案,添加为答案以获得更好的可见性。)

如错误消息所示,您必须将 ENV["CPLEX_STUDIO_BINARIES"] 值设置为包含 cplex 的目录。您可以通过 运行ning which cplex | xargs dirname(或简单地 which cplex 并自己从结果中删除最后的 cplex)找到它。

如果您将 CPLEX_STUDIO_BINARIES 设置为该路径,您可以再次 运行 Pkg.build("CPLEX") 让 CPLEX.jl 从路径中获取二进制文件。