Julia crashes when importing PyPlot

Hi everyone,

I decided to give my MacBookPro (13’’ 2019 Intel) a factory reset and now have a nice and clean set-up. Everything works fine, except importing PyPlot in Julia. Unfortunately, I don’t get any error message other than this

julia> import PyPlot
zsh: killed     Julia

because Julia is just dead. Any ideas what could be wrong? I am using Julia 1.12.2 and PyPlot v2.11.6.

Thank you very much,
Georg

What is the output of

versioninfo()

at the Julia prompt?

It gives more details than just the version. That might be useful.
And what is your MacOS version?

The output is

ulia Version 1.12.2
Commit ca9b6662be4 (2025-11-20 16:25 UTC)
Build Info:
  Official https://julialang.org release
Platform Info:
  OS: macOS (x86_64-apple-darwin24.0.0)
  CPU: 8 × Intel(R) Core(TM) i5-8279U CPU @ 2.40GHz
  WORD_SIZE: 64
  LLVM: libLLVM-18.1.7 (ORCJIT, skylake)
  GC: Built with stock GC
Threads: 1 default, 1 interactive, 1 GC (on 8 virtual cores)

Mac OS is Sequoia 15.7.2

Can you try these instructions:

rm -rf ~/.julia/conda
mkdir MyProject
cd MyProject
julia --project=.

And on the Julia prompt:

using Pkg
ENV["PYTHON"]=""
pkg"add PyPlot"

This results in the following error:

julia> import PyPlot
ERROR: InitError: could not load library "/Users/georg/.julia/conda/3/x86_64/lib/libpython3.12.dylib"
dlopen(/Users/georg/.julia/conda/3/x86_64/lib/libpython3.12.dylib, 0x0009): tried: '/Users/georg/.julia/conda/3/x86_64/lib/libpython3.12.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/georg/.julia/conda/3/x86_64/lib/libpython3.12.dylib' (no such file), '/Users/georg/.julia/conda/3/x86_64/lib/libpython3.12.dylib' (no such file)
Stacktrace:
  [1] #dlopen#3
    @ ./libdl.jl:120
  [2] dlopen
    @ ./libdl.jl:119 [inlined]
  [3] __init__()
    @ PyCall ~/.julia/packages/PyCall/1gn3u/src/pyinit.jl:149
  [4] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1440
  [5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1428
  [6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any}; register::Bool)
    @ Base ./loading.jl:1316
  [7] _include_from_serialized
    @ ./loading.jl:1271 [inlined]
  [8] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool; reasons::Dict{…}, DEPOT_PATH::Vector{…})
    @ Base ./loading.jl:2099
  [9] _require_search_from_serialized
    @ ./loading.jl:2006 [inlined]
 [10] __require_prelocked(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:2624
 [11] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2490
 [12] macro expansion
    @ ./loading.jl:2418 [inlined]
 [13] macro expansion
    @ ./lock.jl:376 [inlined]
 [14] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2383
 [15] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2359
 [16] top-level scope
    @ REPL[4]:1
during initialization of module PyCall
Some type information was truncated. Use `show(err)` to see complete types.

I have had plenty of problems with PyPlot since Julia 1.12, probably related to threads. In the end I migrated to PythonPlot.

Unfortunately this did not help. Adding it resulted in

(@v1.12) pkg> add PythonPlot
   Resolving package versions...
    Updating `~/.julia/environments/v1.12/Project.toml`
  [274fc56d] + PythonPlot v1.0.6
    Updating `~/.julia/environments/v1.12/Manifest.toml`
  [3da002f7] + ColorTypes v0.12.1
  [5ae59095] + Colors v0.13.1
  [992eb4ea] + CondaPkg v0.2.33
  [53c48c17] + FixedPointNumbers v0.8.5
  [0f8b85d8] + JSON3 v1.14.3
  [1914dd2f] + MacroTools v0.5.16
  [0b3b1443] + MicroMamba v0.1.14
  [fa939f87] + Pidfile v1.3.0
  [6099a3de] + PythonCall v0.9.30
  [274fc56d] + PythonPlot v1.0.6
  [6c6a2e73] + Scratch v1.3.0
  [856f2bd8] + StructTypes v1.11.0
  [e17b2a0c] + UnsafePointers v1.0.0
  [81def892] + VersionParsing v1.3.0
⌅ [f8abcde7] + micromamba_jll v1.5.12+0
  [4d7b5844] + pixi_jll v0.41.3+0
  [0dad84c5] + ArgTools v1.1.2
  [f43a241f] + Downloads v1.7.0
  [7b1f6079] + FileWatching v1.11.0
  [4af54fe1] + LazyArtifacts v1.11.0
  [b27032c2] + LibCURL v0.6.4
  [76f85450] + LibGit2 v1.11.0
  [44cfe95a] + Pkg v1.12.0
  [a4e569a6] + Tar v1.10.0
  [deac9b47] + LibCURL_jll v8.15.0+0
  [e37daf67] + LibGit2_jll v1.9.0+0
  [29816b5a] + LibSSH2_jll v1.11.3+1
  [8e850ede] + nghttp2_jll v1.64.0+1
  [3f19e933] + p7zip_jll v17.7.0+0
        Info Packages marked with ⌅ have new versions available but compatibility constraints restrict them from upgrading. To see why use `status --outdated -m`

Now importing the package kills the Julia again. Also removing the package, garbage collecting, and adding it again does not fix the problem. Although, there is no error message when adding it. However, it just crashes.

Do you have similar errors with PyCall.jl and/or PythonCall.jl ?

Adding and importing PythonCall works. After adding PyCall, however, import PyCall results in

julia> import PyCall
ERROR: InitError: could not load library "/Users/georg/.julia/conda/3/x86_64/lib/libpython3.12.dylib"
dlopen(/Users/georg/.julia/conda/3/x86_64/lib/libpython3.12.dylib, 0x0009): tried: '/Users/georg/.julia/conda/3/x86_64/lib/libpython3.12.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/Users/georg/.julia/conda/3/x86_64/lib/libpython3.12.dylib' (no such file), '/Users/georg/.julia/conda/3/x86_64/lib/libpython3.12.dylib' (no such file)
Stacktrace:
  [1] #dlopen#3
    @ ./libdl.jl:120
  [2] dlopen
    @ ./libdl.jl:119 [inlined]
  [3] __init__()
    @ PyCall ~/.julia/packages/PyCall/1gn3u/src/pyinit.jl:149
  [4] run_module_init(mod::Module, i::Int64)
    @ Base ./loading.jl:1440
  [5] register_restored_modules(sv::Core.SimpleVector, pkg::Base.PkgId, path::String)
    @ Base ./loading.jl:1428
  [6] _include_from_serialized(pkg::Base.PkgId, path::String, ocachepath::String, depmods::Vector{Any}; register::Bool)
    @ Base ./loading.jl:1316
  [7] _include_from_serialized
    @ ./loading.jl:1271 [inlined]
  [8] _require_search_from_serialized(pkg::Base.PkgId, sourcepath::String, build_id::UInt128, stalecheck::Bool; reasons::Dict{…}, DEPOT_PATH::Vector{…})
    @ Base ./loading.jl:2112
  [9] _require_search_from_serialized
    @ ./loading.jl:2006 [inlined]
 [10] __require_prelocked(pkg::Base.PkgId, env::String)
    @ Base ./loading.jl:2624
 [11] _require_prelocked(uuidkey::Base.PkgId, env::String)
    @ Base ./loading.jl:2490
 [12] macro expansion
    @ ./loading.jl:2418 [inlined]
 [13] macro expansion
    @ ./lock.jl:376 [inlined]
 [14] __require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2383
 [15] require(into::Module, mod::Symbol)
    @ Base ./loading.jl:2359
 [16] top-level scope
    @ REPL[6]:1
during initialization of module PyCall
Some type information was truncated. Use `show(err)` to see complete types.

Did you consider setting the Python path manually and rebuilding PyCall.jl?

You may also need to install matplotlib in your python environment.

1 Like

I didn’t.

I am not sure what to set it to. Currently there is no python installation on my machine. To my understanding, this why the Julia packages try building a minimal python installation using miniconda.

There is currently also no entry "Python" in my ENV.

julia> ENV
Base.EnvDict with 29 entries:
  "__CFBundleIdentifier"         => "com.apple.Terminal"
  "TMPDIR"                       => "/var/folders/cd/gnnpy0j96vxc99wdm1p03h5m0000gn/T/"
  "XPC_FLAGS"                    => "0x0"
  "LaunchInstanceID"             => "3A30F679-31A4-4ECD-A483-001718CBA49F"
  "TERM"                         => "xterm-256color"
  "SSH_AUTH_SOCK"                => "/private/tmp/com.apple.launchd.P1NsbIKk3B/Listeners"
  "SECURITYSESSIONID"            => "186a1"
  "XPC_SERVICE_NAME"             => "0"
  "TERM_PROGRAM"                 => "Apple_Terminal"
  "TERM_PROGRAM_VERSION"         => "455.1"
  "TERM_SESSION_ID"              => "38EAAAA0-1A63-4AF6-9FFA-5C6F84A62482"
  "SHELL"                        => "/bin/zsh"
  "HOME"                         => "/Users/georg"
  "LOGNAME"                      => "georg"
  "USER"                         => "georg"
  "PATH"                         => "/Users/georg/.julia/environments/v1.12/.CondaPkg/.pixi/envs/default/bin:/Users/…
  "SHLVL"                        => "1"
  "PWD"                          => "/Users/georg"
  "OLDPWD"                       => "/Users/georg/.julia/conda/3/x86_64/lib"
  "LANG"                         => "de_DE.UTF-8"
  "_"                            => "/Users/georg/.juliaup/bin/julia"
  "__CF_USER_TEXT_ENCODING"      => "0x1F5:0x0:0x3"
  "OPENBLAS_MAIN_FREE"           => "1"
  "OPENBLAS_DEFAULT_NUM_THREADS" => "1"
  "CONDA_PREFIX"                 => "/Users/georg/.julia/environments/v1.12/.CondaPkg/.pixi/envs/default"
  "CONDA_DEFAULT_ENV"            => "/Users/georg/.julia/environments/v1.12/.CondaPkg/.pixi/envs/default"
  "CONDA_SHLVL"                  => "1"
  "CONDA_PROMPT_MODIFIER"        => "(/Users/georg/.julia/environments/v1.12/.CondaPkg/.pixi/envs/default) "
  "PYTHON_JULIACALL_INIT"        => "no"

Should I try installing some Python to my machine and then link it?

For rebuilding PyCall you could try, before adding PyPlot:

julia -e 'ENV["PYTHON"]=""; using Pkg; Pkg.add("PyCall"); Pkg.build("PyCall")'

This installs Python in a subfolder of .julia.

In case that threading should cause a problem you can start Julia with:

julia -t 1

which disables the interactive thread introduced in Julia 1.12.