Segfault when using PythonCall.jl with Plots.jl

I have a package that uses PythonCall.jl to import and use the python library TTS. Importing Plots.jl seems to be causing a segmentation fault. Below is a minimum working example. If I import Pytest and then call f(), it causes a segmentation fault.

If I just include(Pytest.jl) from a julia session, do using .Pytest and call f(), I still get a segmentation fault when Plots.jl is imported.

I can switch to another plotting package for now, but wanted to post here in case people think this is important or in case anyone thinks I’m doing silly things I shouldn’t be doing.

Complete package (the contents of Pytest.jl):

module Pytest

ENV["COQUI_STUDIO_TOKEN"] = "TOKEN_HERE" # need this to initially download files for TTS
conda_environment_directory = joinpath(@__DIR__, "..", ".CondaPkg", "env")
ENV["JULIA_CONDAPKG_ENV"]   =          conda_environment_directory
ENV["JULIA_PYTHONCALL_EXE"] = joinpath(conda_environment_directory, "bin", "python")

using PythonCall
# using Plots # causing segfault?

const p = Ref{Py}()
function __init__()
    p[] = pyimport("TTS.api").TTS

    return nothing

f() = p[]("tts_models/en/jenny/jenny")

export f


Other information:

julia> versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
  Official release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M1
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, apple-m1)
Threads: 1 default, 0 interactive, 1 GC (on 4 virtual cores)

contents of Project.toml

name = "Pytest"
uuid = "f50a81a1-bcd7-43e0-a2d7-f0249198ada0"
authors = ["sadish "]
version = "0.1.0"

CondaPkg = "992eb4ea-22a4-4c89-a5bb-47a3300528ab"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
PythonCall = "6099a3de-0909-46bc-b1f4-468b9a2dfc0d"

contents of CondaPkg.toml

python = "=3.11"

tts = ""
1 Like

Update: import CairoMakie instead of import Plots also causes the same error. Any ideas?

Tagging @cjdoris to see if they have any insights.