# System image with PyPlot.jl

**URL:** <https://discourse.julialang.org/t/system-image-with-pyplot-jl/107320>\
**Category:** General Usage\
**Tags:** question, pyplot, package-compiler\
**Created:** [December 8, 2023, 9:31am UTC](https://discourse.julialang.org/t/system-image-with-pyplot-jl/107320 "2023-12-08T09:31:13Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [December 8, 2023, 9:31am UTC](https://discourse.julialang.org/t/system-image-with-pyplot-jl/107320/1 "2023-12-08T09:31:14Z")

</div>

I created a small project, see: [GitHub - ufechner7/Tethers.jl: Tether models](https://github.com/ufechner7/Tethers.jl)

For now the code is trivial, but to avoid high time-to-first plot I created a custom system image with ModelingToolkit, OrdinaryDiffEq, and PyPlot.

The problem is that when launching Julia with this image PyPlot does not show any figures any more by default. It DOES show the figure if I call the function `show()` at the end of my script, but this is blocking, in other words I cannot longer interactively show multiple plots.

How can I fix this problem?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [December 8, 2023, 9:46am UTC](https://discourse.julialang.org/t/system-image-with-pyplot-jl/107320/2 "2023-12-08T09:46:39Z")

</div>

For reasons I do not fully understand it is working now. I use the call:

```julia
PyPlot.show(block=false)

```

which is working today. It was not working yesterday, though…

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [December 8, 2023, 11:04am UTC](https://discourse.julialang.org/t/system-image-with-pyplot-jl/107320/3 "2023-12-08T11:04:38Z")

</div>

Why are you using PyPlot/PyCall? I believe PythonPlot is a drop-in replacement, though not sure it fixes this, using PythonCall. You don’t use PyCall for anything else there, and you can actually use it with PythonCall (if doing it right), in case you worry about that.

When you’re making a sysimage it’s for faster startup, and maybe to send to others. PythonCall has a bit slower startup but would take care of dependencies.

I.e. the sysimage would be self-contained, but with PyCall it’s not (not for any Python dependency), needing installation of Python and matplotlib manually, right?

I see [[deps.PackageCompiler]] in the manifest, not a worry, I’m just thinking what really ends up in the sysimage, also it?

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [December 8, 2023, 11:58am UTC](https://discourse.julialang.org/t/system-image-with-pyplot-jl/107320/4 "2023-12-08T11:58:18Z")

</div>

> [@Palli](#):
>
> Why are you using PyPlot/PyCall? I believe PythonPlot is a drop-in replacement, though not sure it fixes this, using PythonCall. You don’t use PyCall for anything else there, and you can actually use it with PythonCall (if doing it right), in case you worry about that.

I tried PythonPlot, but it is not working for me, see bug: [Qt5 "No working GUI backend found for matplotlib" · Issue #17 · JuliaPy/PythonPlot.jl · GitHub](https://github.com/JuliaPy/PythonPlot.jl/issues/17)

And PyPlot also installs Python and Matplotlib if it is not installed already. I don’t care if the sysimage is self-contained as long as the startup time is low (and in the moment my first-time-to-plot with ModelingToolkit and OrdinaryDiffEq is 0.2 seconds). 🙂

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [December 8, 2023, 12:00pm UTC](https://discourse.julialang.org/t/system-image-with-pyplot-jl/107320/5 "2023-12-08T12:00:06Z")

</div>

> [@Palli](#):
>
> I see [[deps.PackageCompiler]] in the manifest, not a worry, I’m just thinking what really ends up in the sysimage, also it?

As you can see:

```julia
@info "Loading packages ..."
using ModelingToolkit, OrdinaryDiffEq, PackageCompiler, PyPlot

@info "Creating sysimage ..."
push!(LOAD_PATH,joinpath(pwd(),"src"))

PackageCompiler.create_sysimage(
    [:ModelingToolkit, :OrdinaryDiffEq, :PyPlot];
    sysimage_path="kps-image_tmp.so",
    precompile_execution_file=joinpath("test", "test_for_precompile.jl")
)

```

PackageCompiler will not end up in the sysimage.
