Python and ROOT Tricks: batch mode, please!

If you’ve tried to write a Python program that uses ROOT, you might see complaints about “not having permission to access your DISPLAY.” What is happening is that ROOT is trying to access the graphics capabilities of your shell, but for some reason it cannot. This often happens if you’ve logged into a remote computer but have either forgotten to tunnel the graphics connection from the remote machine, or you’ve otherwise somehow lost the permission to do that.

Never fear! You can still run your program; you just need ROOT to go into “batch” mode, where it doesn’t try to actively popup graphics on the screen. To do this, import ROOT as usual but then tell ROOT to run in batch mode:

import ROOT
ROOT.gROOT.SetBatch(True)

You’re good to go; now anything you do with ROOT will not require permission to access the display, and you can generate plots and save them to disk, etc.

Leave a Reply

Your email address will not be published. Required fields are marked *