# Numpy and PyCall issues

**URL:** <https://discourse.julialang.org/t/numpy-and-pycall-issues/85847>\
**Category:** General Usage\
**Tags:** pycall\
**Created:** [August 16, 2022, 8:54pm UTC](https://discourse.julialang.org/t/numpy-and-pycall-issues/85847 "2022-08-16T20:54:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Derek\_Vetsch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/derek_vetsch/32/8552_2.png) [@Derek\_Vetsch](https://discourse.julialang.org/u/Derek_Vetsch)\
**Post date:** [August 16, 2022, 8:54pm UTC](https://discourse.julialang.org/t/numpy-and-pycall-issues/85847/1 "2022-08-16T20:54:29Z")

</div>

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:

```julia
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:

```julia
ENV["PYTHON"] = <path to my python executable>
Pkg.build("PyCall")
using PyCall
pyimport("numpy")

```

As well as using `Conda.jl`:

```julia
using Conda, PyCall
Conda.add("numpy")
pyimport("numpy")

```

What am I doing wrong? Thanks!

---

<div class="post-metadata">

**Author:** ![mkitti](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mkitti/32/12459_2.png) [@mkitti](https://discourse.julialang.org/u/mkitti)\
**Post date:** [August 16, 2022, 9:12pm UTC](https://discourse.julialang.org/t/numpy-and-pycall-issues/85847/2 "2022-08-16T21:12:55Z")

</div>

Do you need a specific python environment to work or will just any do? It might be easiest to redo the above but set `ENV["PYTHON"] = ""` then repeat what you did above as described [here](https://github.com/JuliaPy/PyCall.jl#specifying-the-python-version).

---

<div class="post-metadata">

**Author:** ![Derek\_Vetsch](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/derek_vetsch/32/8552_2.png) [@Derek\_Vetsch](https://discourse.julialang.org/u/Derek_Vetsch)\
**Post date:** [August 17, 2022, 3:14am UTC](https://discourse.julialang.org/t/numpy-and-pycall-issues/85847/3 "2022-08-17T03:14:22Z")

</div>

UGH So sorry I thought I tried that but it looks like I forgot to reset my `ENV["PYTHON"]`. Thanks
