api python库:raise AttributeError(“No constructor defined”)

我尝试使用saga_api库执行一个python脚本,不幸的是我在第一步停止:(当我在托盘上执行这个命令时:python: aga_api.CSG_Module_Library()我有这个错误信息:

def init(self, args, *kwargs):
    raise AttributeError("No constructor defined")
        AttributeError: No constructor defined

并且它在Windows上也是同样的东西!

你能帮助我超越这一步吗?!

System : Ubuntu 13.10 x64
python version : 2.7.5+
saga_api library version : 2.1.1
SAGA program version : 2.1.1
swig version : 2.0.10

这是代码:

!/ usr / bin / env python

导入saga_api,sys,os

def Import_raster(in_grid):

print saga_api.SAGA_API_Get_Version()

fmlb = '/usr/lib/saga/libio_gdal.so'

Library = saga_api.CSG_Module_Library() # here is the bug !!!

if Library.Create(saga_api.CSG_String(fmlb)) == 0:
    print 'unable to load SAGA module library'
    return 0

print '... success'

Module = Library.Get_Module('GDAL: Import Raster')

Parms = Module.Get_Parameters()
Parms('FILES').Set_Value(in__grid) 
Parms('SELECT').Set_Value(1) 
Parms('TRANSFORM').Set_Value(0)
Parms('INTERPOL').Set_Value(0)

Parms = Module.Get_Parameters(0) # additional parameter list

print Module.Get_Name() + ': ' + Parms('FILE').asString()

if Module.Execute() == 0:
    print 'module execution failed'
    return 0
print 'module successfully executed'

print 'save as SAGA grid'
if Parms('GRID').asGrid().Save(saga_api.CSG_String(in__grid)) == 0:
    print '... failed'
    return 0
print '... success'

return 1

如果name ==' main ':

if len( sys.argv ) != 4:
    print 'Usage: this_script.py <in: gridfile> <out: gridfile> <in: shapefile> <out: shapefile>'
    in__grid = '/home/.../CC432_landsat8.tif'
    in__grid = os.path.abspath(in__grid)

else:
    in__grid = sys.argv[1]

    if os.path.split(in__grid)[0] == '':
        in__grid    = './' + in__grid

Import_raster(in__grid)

打印“完成!”

这里是init:.... class CSG_Module_Library(_object): swig_setmethods = {} setattr = lambda self,name,value:_swig_setattr(self,CSG_Module_Library,name,value) swig_getmethods = {} getattr = lambda self,name:_swig_getattr (self,CSG_Module_Library,name)def init (self,* args,** kwargs):raise AttributeError(“No constructor defined”) repr = _swig_repr def is_Valid(self):return _saga_api.CSG_Module_Library_is_Valid(self)def Get_File_Name(self) :return _saga_api.CSG_Module_Library_Get_File_Name(self)def Get_Library_Name(self):return _saga_api.CSG_Module_Library_Get_Library_Name(self)def Get_Info(self,* args):return _saga_api.CSG_Module_Library_Get_Info(self,* args)def Get_Name(self):return _saga_api.CSG_Module_Library_Get_Name (self)def Get_Description(self):return _saga_api.CSG_Module_Library_Get_Description(self)def Get_Author(self):return _saga_api.CSG_Module_Library_Get_Author(self)def Get_Version(self):return _saga_api.CSG_Module_Library_Get_Version(self)def Get_Menu(self,* args):return _saga_api.CSG_Module_Library_Get_Menu(self,* args) def Get_Module(self,* args):return _saga_api.CSG_Module_Library_Get_Module(self,* args)def Get_Module_Grid(self,* args):return _saga_api.CSG_Module_Library_Get_Module_Grid(self,* args)def Get_Module_Interactive(self,* args):return _saga_api。 CSG_Module_Library_Get_Module_Interactive(个体经营,*参数)高清Get_Module_Grid_Interactive(个体经营,*参数):返回_saga_api.CSG_Module_Library_Get_Module_Grid_Interactive(个体经营,*参数)CSG_Module_Library_swigregister = _saga_api.CSG_Module_Library_swigregister CSG_Module_Library_swigregister(CSG_Module_Library)....

链接地址: http://www.djcxy.com/p/56425.html

上一篇: api python library : raise AttributeError(“No constructor defined”)

下一篇: How to test Python readline completion?