PyCall pyimport() fails and exits julia

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:
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:
using PyCall
py"""
a=1+1
"""
py"a"
  1. Made sure it is running the right python
PyCall.python

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

  1. Importing math package worked as expected:
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
np = pyimport("numpy")
pd = pyimport("pandas")

Any idea what I am doing wrong?

Not sure what’s going wrong here, but you should probably use PythonCall.jl instead, which is more modern and reliable

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.

3 Likes