Mac OS 10.9 : Problem with Python

[quote=“atomdust”]Hi all,

Like many other users I had some problem installing root on the new OS version. The “Git trick” ([url]Locate like command made the trick and things seem to work now.

However I still have a problem with Python. I use the pre build mac version of Python and gcc 4.4.7 installed via MacPorts (I tried the mac prebuilt version first, it leads to the same problem).

Importing ROOT in Python leads to the following error:


[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ROOT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/David/Documents/root/lib/ROOT.py", line 257, in <module>
    _root.gPad         = _ExpandMacroFunction( "TVirtualPad",  "Pad" )
  File "/Users/David/Documents/root/lib/ROOT.py", line 237, in __init__
    c = _root.MakeRootClass( klass )
AttributeError: type object 'string' has no attribute 'c_str'

In ROOT.py, these are the lines that cause the problem :


### special cases for gPad, gVirtualX (are C++ macro's) -------------------------
class _ExpandMacroFunction( object ):
   def __init__( self, klass, func ):
      c = _root.MakeRootClass( klass )
      self.func = getattr( c, func )

   def __getattr__( self, what ):
      return getattr( self.__dict__[ 'func' ](), what )

   def __cmp__( self, other ):
      return cmp( self.func(), other )

   def __len__( self ):
      if self.func():
         return 1
      return 0

_root.gPad         = _ExpandMacroFunction( "TVirtualPad",  "Pad" )
_root.gVirtualX    = _ExpandMacroFunction( "TVirtualX",    "Instance" )
_root.gDirectory   = _ExpandMacroFunction( "TDirectory",   "CurrentDirectory" )
_root.gFile        = _ExpandMacroFunction( "TFile",        "CurrentFile" )
_root.gInterpreter = _ExpandMacroFunction( "TInterpreter", "Instance" )

Any call to _ExpandMacroFunction provokes the error. The comment says “(are C++ macro’s)”, maybe I miss some libraries to make it work.

Does this affect other people ? If not, which version of Python/Gcc do you use ? Any any ideas will be welcomed.

Thanks,
David[/quote]

I have the same problem and it was also reported on the pyRoot forum. Importing ROOT twice works though who knows how successfully:

>>> import ROOT
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/temp/root/lib/root/ROOT.py", line 257, in <module>
    _root.gPad         = _ExpandMacroFunction( "TVirtualPad",  "Pad" )
  File "/usr/local/temp/root/lib/root/ROOT.py", line 237, in __init__
    c = _root.MakeRootClass( klass )
AttributeError: type object 'string' has no attribute 'c_str'
>>> import ROOT
>>>