JuliaPy / JuliaPy/PyCall.jl

PyCall insists upon using system python

Aperta
#886 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Julia
Stelle
1.5k
Fork
186
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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!

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Start with the failing call in PyCall.jl:547 and the reported PyCall.current_python() and pyimport steps. Reproduce the listed Julia, PyCall, and Conda versions, then trace why numpy is loaded from the system Python; done means the import uses the configured Conda Python without the Python 2 PyInit_multiarray error.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
numpy, python
Ambito
tooling
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.