# Segfault when using PythonCall.jl with Plots.jl

**URL:** <https://discourse.julialang.org/t/segfault-when-using-pythoncall-jl-with-plots-jl/112944>\
**Category:** General Usage\
**Tags:** plots, pythoncall\
**Created:** [April 15, 2024, 4:02am UTC](https://discourse.julialang.org/t/segfault-when-using-pythoncall-jl-with-plots-jl/112944 "2024-04-15T04:02:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sadish-d](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sadish-d/32/48058_2.png) [@sadish-d](https://discourse.julialang.org/u/sadish-d)\
**Post date:** [April 15, 2024, 4:02am UTC](https://discourse.julialang.org/t/segfault-when-using-pythoncall-jl-with-plots-jl/112944/1 "2024-04-15T04:02:01Z")

</div>

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):

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

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

export f

end

```

Other information:

```julia
julia> versioninfo()
Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (arm64-apple-darwin22.4.0)
  CPU: 8 × Apple M1
  WORD_SIZE: 64
  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

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

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

```

contents of CondaPkg.toml

```julia
[deps]
python = "=3.11"

[pip.deps]
tts = ""

```

---

<div class="post-metadata">

**Author:** ![sadish-d](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sadish-d/32/48058_2.png) [@sadish-d](https://discourse.julialang.org/u/sadish-d)\
**Post date:** [April 16, 2024, 2:42am UTC](https://discourse.julialang.org/t/segfault-when-using-pythoncall-jl-with-plots-jl/112944/2 "2024-04-16T02:42:47Z")

</div>

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

Tagging @cjdoris to see if they have any insights.
