How to disable print-outs when plotting (for `savefig` on e.g. hpc)

Torkel
Wed, 13 Aug 2025 17:27:21 +0000
Visualization

I am running some code on a hpc server (both interactively in the terminal and using slurm). As part of the process I am getting print outs like

qt.qpa.xcb: could not connect to display localhost:13.0
qt.qpa.plugin: From 6.5.0, xcb-cursor0 or libxcb-cursor0 is needed to load the Qt xcb platform plugin.
qt.qpa.plugin: Could not load the Qt platform plugin "xcb" in "" even though it was found.
This application failed to start because no Qt platform plugin could be initialized. Reinstalling the application may fix this problem.

Available platform plugins are: eglfs, linuxfb, minimal, minimalegl, offscreen, vkkhrdisplay, vnc, xcb.

connect: Connection refused
GKS: can't connect to GKS socket application

GKS: Open failed in routine OPEN_WS
GKS: GKS not in proper state. GKS must be either in the state WSOP or WSAC in routine ACTIVATE_WS

How do I disable this? I am basically doing

savefig(plot(data), "file.png")

Asking chat GPT, I added

# Ensures plots are not dent to display.
begin
    ENV["GKSwstype"] = "100"    # primary
    ENV["GKS_WSTYPE"] = "100"   # older fallback
    ENV["DISPLAY"] = ""         # belt-and-braces: pretend no display
    gr()                        # ensure GR backend
    default(show = false)       # don't try to pop up windows
end

to the start of my script (after using Plots), however, this did not seem to work.

1 post - 1 participant