# PyCall pyimport() fails and exits julia

**URL:** <https://discourse.julialang.org/t/pycall-pyimport-fails-and-exits-julia/104845>\
**Category:** New to Julia\
**Tags:** package\
**Created:** [October 11, 2023, 12:07pm UTC](https://discourse.julialang.org/t/pycall-pyimport-fails-and-exits-julia/104845 "2023-10-11T12:07:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![harsh1kumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/harsh1kumar/32/202320_2.png) [@harsh1kumar](https://discourse.julialang.org/u/harsh1kumar)\
**Post date:** [October 11, 2023, 12:07pm UTC](https://discourse.julialang.org/t/pycall-pyimport-fails-and-exits-julia/104845/1 "2023-10-11T12:07:08Z")

</div>

Hello Good People of Julia,

I have recently started to work with Julia. I am trying to use PyCall and import packages like numpy and pandas but I am encountering an failure. Details below:

1. Before using PyCall, I rebuild the package to point to my specific install of python:

```julia
ENV["PYTHON"] = "/Users/harshkumar/miniconda3/envs/python311/bin/python"
] build PyCall

```

I also ran `Pkg.build("PyCall")` after this.

1. Ran the following lines of code and it all worked fine:

```julia
using PyCall
py"""
a=1+1
"""
py"a"

```

1. Made sure it is running the right python

```julia
PyCall.python

```

It gave the result `"/Users/harshkumar/miniconda3/envs/python311/bin/python" `

1. Importing math package worked as expected:

```julia
math = pyimport("math")
math.pi

```

Result was 3.141592653589793

1. However, if I try to import numpy or pandas, then julia just exists with ` **Killed: 9** ` as the message. No other error appears

```julia
np = pyimport("numpy")
pd = pyimport("pandas")

```

Any idea what I am doing wrong?

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [October 11, 2023, 1:49pm UTC](https://discourse.julialang.org/t/pycall-pyimport-fails-and-exits-julia/104845/2 "2023-10-11T13:49:22Z")

</div>

Not sure what’s going wrong here, but you should probably use [PythonCall.jl](https://github.com/JuliaPy/PythonCall.jl) instead, which is more modern and reliable

---

<div class="post-metadata">

**Author:** ![harsh1kumar](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/harsh1kumar/32/202320_2.png) [@harsh1kumar](https://discourse.julialang.org/u/harsh1kumar)\
**Post date:** [October 11, 2023, 2:45pm UTC](https://discourse.julialang.org/t/pycall-pyimport-fails-and-exits-julia/104845/3 "2023-10-11T14:45:41Z")

</div>

Thank you @gdalle

I tried PythonCall. This time, I didn’t use my pre-installed python, but let it install it’s own version of python. After that, used CondaPkg to install the needed python dependencies like pandas and numpy. That worked for me.
