Dear all,
I want to try pyroot on my computer. And if I run python2 and it works perfectly:
(base) [bogon@Cassandra:] ~/pyroot $ python2
WARNING: Python 2.7 is not recommended.
This version is included in macOS for compatibility with legacy software.
Future versions of macOS will not include Python 2.7.
Instead, it is recommended that you transition to using 'python3' from within Terminal.
Python 2.7.16 (default, Jun 5 2020, 22:59:21)
[GCC 4.2.1 Compatible Apple LLVM 11.0.3 (clang-1103.0.29.20) (-macos10.15-objc- on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from ROOT import TGraph
>>> gr = TGraph('data.txt')
>>> gr.Draw()
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
>>> exit()
But when I run python2 with .py document, the graph became no response. Sometimes it won’t even show the graph.
[bogon@Cassandra:] ~/pyroot $ python2 try.py
Info in <TCanvas::MakeDefCanvas>: created default TCanvas with name c1
The problem is that the python process closes after execution before it has a chance to show the graph to you. In order to keep python open so that you can look at the graphics output, you can start python in interactive mode with python2 -i try.py.
Hello!
Thank you very much! That did solve my problem. But here is another one. My colleague solve this problem by adding input() at the end of his code. But when I do the same thing, the graph shows but has no response. I can’t do anything to the graph. Do you know how to fix it?