I feel like I’ve gotten this to work before, but I can’t remember how. I am trying to stitch together a few different scripts, some in Julia and some in Python. The Python scripts rely on numpy
but when I try to @pyinclude
the files I get the following error:
ERROR: PyError ($(Expr(:escape, :(ccall(#= C:\Users\maa98\.julia\packages\PyCall\7a7w0\src\pyeval.jl:38 =# @pysym(:PyEval_EvalCode), PyPtr, (PyPtr, PyPtr, PyPtr), o, globals, locals))))) <class 'ImportError'>
ImportError("\nImporting the multiarray numpy extension module failed. Most\nlikely you are trying to import a failed build of numpy.\nIf you're working with a numpy git repo, try `git clean -xdf` (removes all\nfiles not under version control). Otherwise reinstall numpy.\n\nOriginal error was: DLL load failed: The specified module could not be found.\n")
File "C:\Users\maa98\.julia\packages\PyCall\7a7w0\src\pyeval.jl", line 1, in <module>
const Py_single_input = 256 # from Python.h
File "C:\Users\maa98\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\__init__.py", line 142, in <module>
from . import add_newdocs
File "C:\Users\maa98\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\add_newdocs.py", line 13, in <module>
from numpy.lib import add_newdoc
File "C:\Users\maa98\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\lib\__init__.py", line 8, in <module>
from .type_check import *
File "C:\Users\maa98\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\lib\type_check.py", line 11, in <module>
import numpy.core.numeric as _nx
File "C:\Users\maa98\AppData\Local\Continuum\anaconda3\lib\site-packages\numpy\core\__init__.py", line 26, in <module>
raise ImportError(msg)
Stacktrace:
[1] pyerr_check
@ C:\Users\maa98\.julia\packages\PyCall\7a7w0\src\exception.jl:62 [inlined]
[2] pyerr_check
@ C:\Users\maa98\.julia\packages\PyCall\7a7w0\src\exception.jl:66 [inlined]
[3] _handle_error(msg::String)
@ PyCall C:\Users\maa98\.julia\packages\PyCall\7a7w0\src\exception.jl:83
[4] macro expansion
@ C:\Users\maa98\.julia\packages\PyCall\7a7w0\src\exception.jl:97 [inlined]
[5] #117
@ C:\Users\maa98\.julia\packages\PyCall\7a7w0\src\pyeval.jl:38 [inlined]
[6] disable_sigint
@ .\c.jl:458 [inlined]
[7] pyeval_(s::String, globals::PyDict{String, PyObject, true}, locals::PyDict{String, PyObject, true}, input_type::Int64, fname::String)
@ PyCall C:\Users\maa98\.julia\packages\PyCall\7a7w0\src\pyeval.jl:37
[8] top-level scope
@ C:\Users\maa98\.julia\packages\PyCall\7a7w0\src\pyeval.jl:230
I’ve already tried reinstalling numpy, so I don’t think the issue is that my numpy is broken (also because I can use it in Python). I’ve tried to use PyCall
two ways:
ENV["PYTHON"] = <path to my python executable>
Pkg.build("PyCall")
using PyCall
pyimport("numpy")
As well as using Conda.jl
:
using Conda, PyCall
Conda.add("numpy")
pyimport("numpy")
What am I doing wrong? Thanks!