System image with PyPlot.jl

I created a small project, see: GitHub - ufechner7/Tethers.jl: Tether models

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?

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

PyPlot.show(block=false)

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

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?

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

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

1 Like

As you can see:

@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.

1 Like