PyROOT Error on Import

I just managed to compile ROOT from master (still trying to test a bug fix), but PyROOT now doesn’t like getting imported. Here is the error message, related to “cppyy” which afaik is a PyPy thing, but I am not using PyPy. I’m showing my Python sys.path to show I am inveed importing the right ROOT version.

I’ve also attached my cmake & build log as a file.

Versions:
ipython: 5.1.0
root: 6.07/07 (cloned from github this morning)
python: 2.7.12
OSX: 10.9.5
clang: 3.6.2
gfortran: 5.4.0

[12:15]~/Software/root/build/bin$ ipython
Python 2.7.12 (default, Jul  3 2016, 13:35:10) 
Type "copyright", "credits" or "license" for more information.

IPython 5.1.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import ROOT
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-1-b332e25ada1f> in <module>()
----> 1 import ROOT

/Users/jfcaron/Software/root/build/lib/ROOT.py in <module>()
     22 ### system and interpreter setup ------------------------------------------------
     23 import os, sys, types
---> 24 import cppyy
     25 
     26 ## there's no version_info in 1.5.2

/Users/jfcaron/Software/root/build/lib/cppyy.py in <module>()
    178          return klass
    179 
--> 180    class _global_cpp( with_metaclass( _ns_meta ) ):
    181       class std( with_metaclass( _stdmeta, object ) ):
    182          stlclasses = ( 'complex', 'pair', \

/Users/jfcaron/Software/root/build/lib/cppyy.py in _global_cpp()
    179 
    180    class _global_cpp( with_metaclass( _ns_meta ) ):
--> 181       class std( with_metaclass( _stdmeta, object ) ):
    182          stlclasses = ( 'complex', 'pair', \
    183             'deque', 'list', 'queue', 'stack', 'vector', 'map', 'multimap', 'set', 'multiset' )

/Users/jfcaron/Software/root/build/lib/cppyy.py in std()
    186             locals()[ name ] = Template( 'std::%s' % name )
    187 
--> 188          string = _backend.CreateScopeProxy( 'string' )
    189 
    190 else:

AttributeError: 'module' object has no attribute 'CreateScopeProxy'

In [2]: ROOT
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-2-72d7b3e1f42a> in <module>()
----> 1 ROOT

NameError: name 'ROOT' is not defined

In [3]: import sys

In [4]: sys.path
Out[4]: 
['',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin',
 '/Users/jfcaron/Software/root/build/lib',
 '/Users/jfcaron/Software/root/build/bin',
 '/Users/jfcaron/Macros',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
 '/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/IPython/extensions',
 '/Users/jfcaron/.ipython']

buildlog.txt (368 KB)

Jean-François,

cppyy.py has existed in PyROOT since a long time. It was used to transfer from PyCintex, so that those uses could import cppyy, rather than import ROOT, and having that work both in v5 (where it’d be PyCintex) and in v6 (where it’d be libPyROOT).

(Aside, almost all tests now pass with a Cling-based cppyy module in PyPy. Hopefully that’ll be out soon.)

Here, the _backend module is (supposed to be) libPyROOT.so. I can not tell based on the posted information whether the proper version is loaded. It should live in $ROOTSYS/lib. You can import it directly to test:

[code]$ python

import libPyROOT
print libPyROOT

[/code]

Cheers,
Wim

libPyROOT is imported properly, but ROOT.py itself is not. I’ve checked ROOTSYS and PYTHONPATH and it all seems to check out.

[code]Python 2.7.12 (default, Jul 3 2016, 13:35:10)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.51)] on darwin
Type “help”, “copyright”, “credits” or “license” for more information.

import libPyROOT
print libPyROOT
<module ‘libPyROOT’ from ‘/Users/jfcaron/Software/root/build/lib/libPyROOT.so’>

import ROOT
Traceback (most recent call last):
File “”, line 1, in
File “/Users/jfcaron/Software/root/build/lib/ROOT.py”, line 24, in
import cppyy
File “/Users/jfcaron/Software/root/build/lib/cppyy.py”, line 180, in
class _global_cpp( with_metaclass( _ns_meta ) ):
File “/Users/jfcaron/Software/root/build/lib/cppyy.py”, line 181, in _global_cpp
class std( with_metaclass( _stdmeta, object ) ):
File “/Users/jfcaron/Software/root/build/lib/cppyy.py”, line 188, in std
string = _backend.CreateScopeProxy( ‘string’ )
AttributeError: ‘module’ object has no attribute ‘CreateScopeProxy’

[13:12]~/Software/root/build$ echo $PYTHONPATH
/Users/jfcaron/Software/root/build/lib
[13:12]~/Software/root/build$ echo $ROOTSYS
/Users/jfcaron/Software/root/build
[13:13]~/Software/root/build$ echo $PATH
/Users/jfcaron/Software/root/build/bin:/opt/local/libexec/root5/bin:/opt/local/libexec/root5/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin
[/code]

Jean-François,

but to be specific, does this work:[code]>>> import libPyROOT

libPyROOT.CreateScopeProxy

[/code]
as that is what it’s supposed to pick up. (Not really sure how it could fail per se, as the libPyROOT that does not have CreateScopeProxy would have to be v5 or ancient v6, so just trying to eliminate things.)

Cheers,
Wim