Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/356.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 导入直方图时出现Pyroot AttributeError错误_Python_Linux_Root Framework_Pyroot - Fatal编程技术网

Python 导入直方图时出现Pyroot AttributeError错误

Python 导入直方图时出现Pyroot AttributeError错误,python,linux,root-framework,pyroot,Python,Linux,Root Framework,Pyroot,我对派洛特有意见。当我尝试导入根直方图时,我总是得到相同的AttributeError >>> from ROOT import TH1F AttributeError: type object 'TArray' has no attribute '__getitem__' During handling of the above exception, another exception occurred: SystemError: <built-in method

我对派洛特有意见。当我尝试导入根直方图时,我总是得到相同的AttributeError

>>> from ROOT import TH1F
AttributeError: type object 'TArray' has no attribute '__getitem__'

During handling of the above exception, another exception occurred:

SystemError: <built-in method mro of ROOT.PyRootType object at 0x328fb18> returned a result with an error set
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name 'TH1F'
>>从根目录导入TH1F
AttributeError:类型对象“TArray”没有属性“\uuu getitem\uuu”
在处理上述异常期间,发生了另一个异常:
SystemError:返回了一个带有错误集的结果
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
ImportError:无法导入名称“TH1F”
我还尝试了rootpy,但它不起作用。可能有关系

我已经安装了Python 3.5,并使用gcc 5.2.0对ROOT进行了干净的安装。当我运行
根配置--features
时,会列出Python模块


有什么想法吗?还是解决方案?

您面临的问题与Python最近的一次更改有关,该更改解决了错误的异常处理。
Pythonize.cxx
包装中的一个调用尝试将
\uuu getitem\uuu
属性重命名为不存在的类
TArray
。这导致了一个AttributeError,它在Python中被忽略,直到新的Python 3.5版本发布

要恢复旧的行为,您需要修改
$ROOTSYS/bindings/pyroot/src/
目录中的文件
Utility.cxx
。搜索方法

Bool_t PyROOT::Utility::AddToClass( PyObject* pyclass, const char* label, const char* func )
应该在230号线附近。在该方法中,有一个if条件:

if ( ! pyfunc )
    return kFALSE;
在这里,您需要用以下行替换上面的代码:

if ( ! pyfunc ) {
   PyErr_Clear();
   return kFALSE;
}
调用
PyErr\u Clear()
将解决此问题。保存文件并重新编译根目录安装。这应该可以解决问题


编辑:这个问题已经有一个bug报告:

您面临的问题与Python最近的一次更改有关,该更改解决了错误的异常处理。
Pythonize.cxx
包装中的一个调用尝试将
\uuu getitem\uuu
属性重命名为不存在的类
TArray
。这导致了一个AttributeError,它在Python中被忽略,直到新的Python 3.5版本发布

要恢复旧的行为,您需要修改
$ROOTSYS/bindings/pyroot/src/
目录中的文件
Utility.cxx
。搜索方法

Bool_t PyROOT::Utility::AddToClass( PyObject* pyclass, const char* label, const char* func )
应该在230号线附近。在该方法中,有一个if条件:

if ( ! pyfunc )
    return kFALSE;
在这里,您需要用以下行替换上面的代码:

if ( ! pyfunc ) {
   PyErr_Clear();
   return kFALSE;
}
调用
PyErr\u Clear()
将解决此问题。保存文件并重新编译根目录安装。这应该可以解决问题

编辑:此问题已有错误报告: