5

按照 PyCall.jl 自述文件上的说明,在我的 julia 项目(在它自己的环境中)使用 PyCall 时,我打算使用 pipenv python。

在终端中,我使用 激活了 python 环境pipenv shell,然后找到了 python 的 pipenv 版本的路径文件。PyCall 已经添加到我的 julia 环境中的清单中。在源代码激活的终端中,我启动了 Julia 并输入:ENV["PYCALL_JL_RUNTIME_PYTHON"] = pipenv python environment然后继续运行Pkg.build("PyCall")它安装了 conda。导入 PyCall 时 - using PyCall- 我收到以下错误。

ERROR: InitError: Incompatible `libpython` detected.
`libpython` for C:\Users\me\.virtualenvs\iap\Scripts\python.exe is:
    C:\Users\me\.virtualenvs\iap\Scripts\python37.dll
`libpython` for C:\Users\me\.julia\conda\3\python.exe is:
    C:\Users\me\.julia\conda\3\python36.dll
PyCall.jl only supports loading Python environment using the same `libpython`

我试过重新安装 PyCall,但是 python 环境 libpython 总是抛出这个错误。如何覆盖或以其他方式解决 base julia 的 conda 要求?

我感觉 PyCall 的 Conda 依赖引起了一些libpython问题,并且ENV["PYCALL_JL_RUNTIME_PYTHON"]调用没有正确覆盖 libpython 变量。

4

1 回答 1

2

根据文档PyCall支持venvvirtualenv环境,但您使用的是pipenv. 如果您想使用该PYCALL_JL_RUNTIME_PYTHON变量,我建议您尝试使用任何一种受支持的替代方法。

如果您想继续使用pipenv环境,则可能必须在配置文件中指定PYTHON变量,如下所示:startup.jl

ENV["PYTHON"] = "C:\\path\\to\\your\\pipenv\\python.exe"

然后运行:

julia> using Pkg; Pkg.build("PyCall"); using PyCall
于 2020-01-27T22:41:42.983 回答