我正在使用来自 anaconda 发行版的 python 3.7。
我在使用 pyjulia 从 julia 调用某些函数时遇到问题。
下面是我的代码片段:
import julia
from julia import Julia
julia.Julia(runtime=r"C:\Users\Bruno\AppData\Local\Programs\Julia\Julia-1.4.2\bin\julia.exe")
from julia import SpecialFunctions
SpecialFunctions.polygamma(3,2)
包 SpecialFunctons 引入了可以处理复杂参数的广义多伽玛函数(与 Scipy 的多伽玛相反,它只接受实参)。
问题是,当我运行 polygamma 函数时,我遇到了以下错误:
julia exception: could not load library "libopenlibm"
The specified module could not be found.
Stacktrace:
[1] gamma at C:\Users\Bruno\.julia\packages\SpecialFunctions\LC8dm\src\gamma.jl:573 [inlined]
[2] polygamma(::Int64, ::Float64) at C:\Users\Bruno\.julia\packages\SpecialFunctions\LC8dm\src\gamma.jl:359
[3] polygamma(::Int64, ::Int64) at C:\Users\Bruno\.julia\packages\SpecialFunctions\LC8dm\src\gamma.jl:566
[4] invokelatest(::Any, ::Any, ::Vararg{Any,N} where N; kwargs::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}) at .\essentials.jl:712
[5] invokelatest(::Any, ::Any, ::Vararg{Any,N} where N) at .\essentials.jl:711
[6] _pyjlwrap_call(::Function, ::Ptr{PyCall.PyObject_struct}, ::Ptr{PyCall.PyObject_struct}) at C:\Users\Bruno\.julia\packages\PyCall\zqDXB\src\callback.jl:28
[7] pyjlwrap_call(::Ptr{PyCall.PyObject_struct}, ::Ptr{PyCall.PyObject_struct}, ::Ptr{PyCall.PyObject_struct}) at C:\Users\Bruno\.julia\packages\PyCall\zqDXB\src\callback.jl:49
这意味着 python 无法从 julia 找到 libopenlibm 库,这可能是运行函数 SpecialFunctions.polygamma 所必需的。我不知道如何让 python 看到这个模块。dll libopenlibm.dll.a 显然位于安装 julia 的文件夹中。我尝试重新安装 pyjulia,修改 PATH,并调用 julia 的其他模块(看看这是否会实现一个表)。然而,我没有成功。
不需要此库的其他函数(例如,SpecialFunctions.gamma(x))不存在此问题。
所以,问题可能是:我怎样才能让 python 将这个特定的 julia 库加载到内存中?
任何帮助,将不胜感激。