I have just built root from source on my mac and I need to use PyROOT. The root interpreter is working fine and I am able to open TBrowser, use TCanvas, do calculations, etc. I am also able to do the same with the python interpreter in terminal. I am able to run the example code in the PyRoot Tutorial.
However, there is an issue when I try to run a python script with the same exact code. Anytime TCanvas is opened, a blank screen pops up and if I hold my cursor over the window, I just get the mac loading cursor (the spinning pinwheel) and am unable to do anything with the window except close out and end the script. There is no error message in the terminal so I have no idea how to diagnose the issue.
The issue isn’t that the screen is just flashing momentarily (this is easily solved by just adding an input statement after the TCanvas). I am utterly confused since it seems like my root installation is working but I just can’t run scripts. I am a bit of a beginner so any help is appreciated.
I am running ROOT Version 6.30/04 and I have python version 3.11.7. and I am on a macbook with an Apple M3 pro chip (I have seen online that there may be issues with apple chips and root)
Thank you in advance
ROOT Version: 6.30/04
It’s easier to understand and help if you can provide some minimal code or script that reproduces the issue you describe; since you say that the same code works in some conditions but not in other, try to also show how exactly you are running the code.
The issue occurs for even the simplest code. For example, the following script (call it test.py)
f = ROOT.TF1("f1", "sin(x)/x", 0., 10.)
Now if I run the code above as a python script in terminal (python3 test.py), I get no error message but a blank TCanvas that I cannot interact with as shown in the image below.
However, if I were to run the same code through python prompt as follows, I get a TCanvas window with the proper function.
>>> import ROOT
>>> f = ROOT.TF1("f1", "sin(x)/x", 0., 10.)
input() command. As long as it active it blocks ROOT events processing and therefore graphics does not work or not responsible.
This worked! I had added the input() line to make the TCanvas window persist and this had worked for me in previous versions of root. Now instead I tried using the flag “-i” when running the python script to keep the interpreter alive and this worked! Thank you so much!
Yes, it is important to run python in interactive mode.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.