簡體   English   中英

無法將 PyJulia 與 Julia 1.0 和 Conda Python 3.6 一起使用

[英]Unable to use PyJulia with Julia 1.0 and Conda Python 3.6

我正在嘗試將 Python 和 Julia 配置為使用這些方向進行互操作。

這就是我所做的。

  1. 安裝 Julia 並將julia添加到我的路徑中。
  2. 安裝PyCall.jl
  3. 我使用python3 -m pip install julia安裝了PyJulia 這會將 pyjulia 安裝到我當前的 conda 環境的 python 以及python-jl

現在,我想我了解 conda python 可能由於靜態鏈接 libpython導致的問題。 根據這些說明,您可以通過運行與 PyJulia 一起安裝並使用與系統或任何 conda 安裝發行版分開的 Python 發行版運行的python-jl來繞過此問題。

但是,當我運行其中一個示例測試時python-jl -c 'from julia.Base import banner; banner()' python-jl -c 'from julia.Base import banner; banner()' ,我收到以下錯誤。

ERROR: PyError (PyImport_ImportModule

The Python package julia could not be found by pyimport. Usually this means
that you did not install julia in the Python version being used by PyCall.

PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package.  To install the julia module, you can
use `pyimport_conda("julia", PKG)`, where PKG is the Anaconda
package the contains the module julia, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).

Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python.   As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run Pkg.build("PyCall"), and re-launch Julia.

) <class 'ModuleNotFoundError'>
ModuleNotFoundError("No module named 'julia'")

Stacktrace:
 [1] pyimport(::String) at /Users/austin/.julia/packages/PyCall/0jMpb/src/PyCall.jl:486
 [2] top-level scope at none:0

基於此,我需要將 PyJulia 包julia安裝到 Python 的 Julia 發行版上。 似乎有關於如何執行此pyimport_conda("julia", PKG)的提示pyimport_conda("julia", PKG)但不清楚PKG是什么意思...

其中 PKG 是包含模塊 julia 的 Anaconda 包

從這里開始,我不知道下一步該嘗試什么,或者我是否應該向PyJulia報告問題。 任何幫助,將不勝感激。

我沒有看到您的步驟有任何問題,實際上在我的 Ubuntu 18.04 系統上,它們可以工作(我可以從 python 調用banner()函數)。

我只想試試這個(用python-jl安裝 PyJulia):

python-jl -c "import pip; pip.main(['install', 'Julia'])"

無論如何,打開一個問題,將非常有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM