Pep*_*tch 5 python julia pipenv pycall
按照 PyCall.jl readme 上的说明,在我的 julia 项目(在它自己的环境中)使用 PyCall 时,我打算使用 pipenv python。
在终端中,我使用 激活了python环境pipenv shell,然后找到了pipenv版本的python的路径文件。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`
Run Code Online (Sandbox Code Playgroud)
我试过重新安装 PyCall,但是 python 环境 libpython 总是抛出这个错误。我如何覆盖或以其他方式解决 base julia 的 conda 要求?
我有一种感觉,PyCall 的 Conda 依赖项导致了一些libpython问题,并且该ENV["PYCALL_JL_RUNTIME_PYTHON"]调用没有正确覆盖 libpython 变量。
根据文档PyCall支持venv和virtualenv环境,但您正在使用pipenv. 如果您想使用该PYCALL_JL_RUNTIME_PYTHON变量,我建议您尝试使用任一受支持的替代方案。
如果您想继续使用pipenv环境,则可能必须PYTHON在配置文件中指定变量startup.jl,如下所示:
ENV["PYTHON"] = "C:\\path\\to\\your\\pipenv\\python.exe"
Run Code Online (Sandbox Code Playgroud)
然后运行:
julia> using Pkg; Pkg.build("PyCall"); using PyCall
Run Code Online (Sandbox Code Playgroud)