简体   繁体   English

无法将 PyJulia 与 Julia 1.0 和 Conda Python 3.6 一起使用

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

I'm trying to configure Python and Julia to interoperate using these directions .我正在尝试将 Python 和 Julia 配置为使用这些方向进行互操作。

This is what I've done.这就是我所做的。

  1. Installed Julia and added julia to my path.安装 Julia 并将julia添加到我的路径中。
  2. Installed PyCall.jl安装PyCall.jl
  3. I installed PyJulia using python3 -m pip install julia .我使用python3 -m pip install julia安装了PyJulia This installs pyjulia into my current conda environment's python as well as python-jl .这会将 pyjulia 安装到我当前的 conda 环境的 python 以及python-jl

Now, I think I understand the problems that conda python can cause because of the the statically linked libpython .现在,我想我了解 conda python 可能由于静态链接 libpython导致的问题。 According to those directions, you can bypass this problem by running python-jl which is installed with PyJulia and runs using a distribution of python that is separate from the system or any conda install distributions.根据这些说明,您可以通过运行与 PyJulia 一起安装并使用与系统或任何 conda 安装发行版分开的 Python 发行版运行的python-jl来绕过此问题。

However, when I run one of the example tests python-jl -c 'from julia.Base import banner; banner()'但是,当我运行其中一个示例测试时python-jl -c 'from julia.Base import banner; banner()' python-jl -c 'from julia.Base import banner; banner()' , I receive the following error. 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

Based off of this, I need to install the PyJulia package julia on to the Julia distribution of Python.基于此,我需要将 PyJulia 包julia安装到 Python 的 Julia 发行版上。 There seems to be a hint on how to do this pyimport_conda("julia", PKG) but it's not clear what is meant by PKG ...似乎有关于如何执行此pyimport_conda("julia", PKG)的提示pyimport_conda("julia", PKG)但不清楚PKG是什么意思...

where PKG is the Anaconda package the contains the module julia其中 PKG 是包含模块 julia 的 Anaconda 包

From here, I don't know what to try next or if I should report an issue to PyJulia .从这里开始,我不知道下一步该尝试什么,或者我是否应该向PyJulia报告问题。 Any help would be appreciated.任何帮助,将不胜感激。

I do not see any issue with your steps and in fact on my Ubuntu 18.04 system, they work (I can call the banner() function from python).我没有看到您的步骤有任何问题,实际上在我的 Ubuntu 18.04 系统上,它们可以工作(我可以从 python 调用banner()函数)。

I would just try this (install PyJulia explicely with python-jl ):我只想试试这个(用python-jl安装 PyJulia):

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

In any case, opening an issue, would be very useful.无论如何,打开一个问题,将非常有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM