PyCall pyimport segfault for the poliastro module

I am trying to use the package poliastro with PyCall.

The following lines of code work fine:

using PyCall
poliastro_body = pyimport("poliastro.bodies")
poliastro_planes = pyimport("poliastro.frames")

These do not:

poliastro_orbit = pyimport("poliastro.twobody")
poliastro_maneuver = pyimport("poliastro.maneuver")

The ones that do not cause a segmentation fault that crashes julia. keys(pyimport("poliastro")) returns:
:builtins
:cached
:doc
:file
:loader
:name
:package
:path
:spec
:version
:bodies
:constant
:frames

So I checked inside the directory where Conda installed the packages and everything seems to be there. There is a maneuver.py just like there is a bodies.py.

Iā€™m at a loss, how do I fix this?

A segfault on import often means that they link to a conflicting version of some shared library used by Julia.

It looks like a basic problem with poliastro is that it uses numba, which uses LLVM, which is also used by Julia, but if Julia and Numba link to conflicting versions of LLVM it may crash upon load. See e.g. Segfault importing numba and Using numba and julia (or any other LLVM loader) leads to segfaults. The only workaround is to build numba differently. The linked issues suggest using conda install -c numba llvmlite, for example.

1 Like

Thanks, this is the correct answer, with one very small modification I want to add for anyone who stumbles on this post. PyCall uses a Julia specific installation of python. To make the switch in Julia I used:

Conda.add("numba::llvmlite")

1 Like