Ah sorry, I ran f = ROOT.TF1("f1", "sin(x)/x", 0., 10.), it’s from the Example in Interactive graphics for PyROOT and the invalid expression in this post, still got the same error.
So it seems to be something more than just the invalid expression.
What version of ROOT and python do you use? f = ROOT.TF1("f1", "sin(x)/x", 0., 10.) worked for me with ROOT 6.18/04 and python 2.7.16…
You can check with root --version and python --version in terminal
~ root-config --version (cern-root)
6.22/08
~ python (cern-root)
Python 3.9.2 | packaged by conda-forge | (default, Feb 21 2021, 05:02:46)
[GCC 9.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT; f = ROOT.TF1("f1", "sin(x)/x", 0., 10.)
>>>
There might be something wrong with your environment/installation.
This does not (from ROOT import * rather than import ROOT):
>>> from ROOT import *
>>> ROOT.TF1
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: <namespace cppyy.gbl.ROOT at 0x55a259620340> has no attribute 'TF1'. Full details:
type object 'ROOT' has no attribute 'TF1'
'ROOT::TF1' is not a known C++ class
'TF1' is not a known C++ template
'TF1' is not a known C++ enum
>>>
See https://root.cern/install for supported installation methods. Feel free to open a bug report with ROOT or the relevant package manager (conda, homebrew…) in case you believe your installation should just work.