Display error at WSL

I install root in WSL. And I write a simple code which draw graph. I sure that the code hasn’t problem. But the graph isn’t invoked and following massage occurs;

Error in TGClient::TGClient: can’t open display “:0”, switching to batch mode…
In case you run from a remote ssh session, reconnect with ssh -Y
Info in TCanvas::MakeDefCanvas: created default TCanvas with name c1
(int) 0

What should I do?

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

Hello @Keistad,

As @dastudillo said (thanks for the contribution!) you need to run an X11 server to be able to use graphical output.


Thanks for your advice.

When WSL, installing X11 and adding “export DISPLAY=:0” to bashrc is right.
But inserting “export DISPLAY=$(grep -oP “(?<=nameserver ).+” /etc/resolv.conf):” to bashrc is good for WSL2.

I write this reply for adventure who is annoyed by same problem.