How to run python file?

I‘ve install root via homebrew in my mac,using Xcode,but can’t run python files.what should I do then?thanks!

Welcome to the ROOT forum.

Our python expert is @etejedor but he will need more details to help you. What did you try to “run python” ? have you some script producing errors/problems ?

Hi,sorry.Now I’ve put the errors produced.Thanks.

Processing rf203_ranges.py…

In file included from input_line_8:1:

/opt/homebrew/Cellar/root/6.26.06_1/share/doc/root/tutorials/roofit/rf203_ranges.py:1:1: error: expected unqualified-id

/opt/homebrew/Cellar/root/6.26.06_1/share/doc/root/tutorials/roofit/rf203_ranges.py:14:3: error: invalid preprocessing directive

/opt/homebrew/Cellar/root/6.26.06_1/share/doc/root/tutorials/roofit/rf203_ranges.py:15:3: error: invalid preprocessing directive

Hello,

Can you give more details on what you execute and how you get those errors?

Hello,

I execute the python file’rf203_ranges.py ‘in the ‘roofit’ directory .Then got the errors below:

In file included from input_line_8:1:

/opt/homebrew/Cellar/root/6.26.06_1/share/doc/root/tutorials/roofit/rf203_ranges.py:1:1:error: expected unqualified-id

/opt/homebrew/Cellar/root/6.26.06_1/share/doc/root/tutorials/roofit/rf203_ranges.py:14:3:error: invalid preprocessing directive

/opt/homebrew/Cellar/root/6.26.06_1/share/doc/root/tutorials/roofit/rf203_ranges.py:15:3:error: invalid preprocessing directive

The following mistakes are the same as above.

Hello,

How do you execute it?

You need to do: python name_of_the_file with the same Python your ROOT installation was built for.

oh~sorry,I’m a freshman in the root.I tried to execute it by "python3 rf_ranges.py"then it gives me the result:Info in <TCanvas: :Print>: file rf203_ranges.png has been created

but I can’t see the picture.Do I need to install TCanvas?thanks

Your script created the following png image:

rf203_ranges.png

You should have this file in the folder where you ran the script. Open this image with your favorite image browser and you will see the result.

I find it!Thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.