JuliaPy / JuliaPy/PyCall.jl

PyCall insists upon using system python

オープン
#886 コメント 2 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Julia
スター
1.5k
フォーク
186
PR マージ指標
30日以内にマージされた PR はありません

説明

Julia version: 1.5.2
PyCall version: 1.92.2
Conda version: 1.5.1

Setup
```
ENV["PYTHON"]=""
]add Conda
Conda.add("numpy")
]add PyCall
]build PyCall
```

Check some variables:
```
julia> PyCall.conda
true
julia> PyCall.current_python()
"/home/rkurchin/.julia/conda/3/bin/python"
```

Now here's the problem:
```
np = pyimport("numpy") # same error results from np = pyimport_conda("numpy","numpy")
```

And here's the output...
```
ERROR: PyError (PyImport_ImportModule

The Python package numpy could not be imported by pyimport. Usually this means
that you did not install numpy 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 numpy module, you can
use `pyimport_conda("numpy", PKG)`, where PKG is the Anaconda
package the contains the module numpy, 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.

)
ImportError('dynamic module does not define module export function (PyInit_multiarray)')
File "/opt/ohpc/pub/libs/gnu/numpy/1.9.2/lib64/python2.7/site-packages/numpy/__init__.py", line 170, in
from . import add_newdocs
File "/opt/ohpc/pub/libs/gnu/numpy/1.9.2/lib64/python2.7/site-packages/numpy/add_newdocs.py", line 13, in
from numpy.lib import add_newdoc
File "/opt/ohpc/pub/libs/gnu/numpy/1.9.2/lib64/python2.7/site-packages/numpy/lib/__init__.py", line 8, in
from .type_check import *
File "/opt/ohpc/pub/libs/gnu/numpy/1.9.2/lib64/python2.7/site-packages/numpy/lib/type_check.py", line 11, in
import numpy.core.numeric as _nx
File "/opt/ohpc/pub/libs/gnu/numpy/1.9.2/lib64/python2.7/site-packages/numpy/core/__init__.py", line 6, in
from . import multiarray

Stacktrace:
[1] pyimport(::String) at /home/rkurchin/.julia/packages/PyCall/tqyST/src/PyCall.jl:547
[2] top-level scope at REPL[17]:1
```

Note that the stacktrace shows the system python (2.7) as opposed to the Conda.jl Python 3 that it should be using. This PyInit_multiarray seems to be a documented error arising when using Python 2 where Python 3 is needed.

OS details:
```
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"
```

The really weird part is I've gotten this to work perfectly on another system with the same OS and the only difference between the two that I can figure out is that the other system is running Julia 1.5.1 whereas this one is on 1.5.2.

I've completely run out of troubleshooting ideas here and would love any input!

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

調査の方向性

PyCall.jl:547 の失敗している呼び出しと、報告されている PyCall.current_python() および pyimport の手順から始めます。記載されている Julia、PyCall、Conda のバージョンを再現し、その後、なぜ numpy がシステムの Python から読み込まれるのかを追跡します。Python 2 の PyInit_multiarray エラーなしで、インポートが設定済みの Conda Python を使用すれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
numpy, python
領域
tooling
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。