ömer sarı ömer sarı - 9 months ago 62
Python Question

Imagine module has no modeler attribute

l'm trying to do layerstack operations by using Python. However, l get stuck in an error.

here is example code:

import os,sys
from imagine import modeler

m = modeler.Model()

# Import Bands 1-7
ri1 = m.RasterInput(path + “/” + folderName + “_B1.TIF”)
ri2 = m.RasterInput(path + “/” + folderName + “_B2.TIF”)
ri3 = m.RasterInput(path + “/” + folderName + “_B3.TIF”)
ri4 = m.RasterInput(path + “/” + folderName + “_B4.TIF”)
ri5 = m.RasterInput(path + “/” + folderName + “_B5.TIF”)
ri6 = m.RasterInput(path + “/” + folderName + “_B6.TIF”)
ri7 = m.RasterInput(path + “/” + folderName + “_B7.TIF”)

stackbands = m.StackLayers(ri1,ri2,ri3,ri4,ri5,ri6,ri7)
outputFile = path + “/” + folderName + “-msi.img”
ro = m.RasterOutput(stackbands, outputFile)
print “\nCreating MS image using bands 1-7…”

l got an error during
from imagine import modeler
and the error is here:

ImportError: cannot import name 'modeler'

l installed
pip install imagine
but in imagine module has no modeler attribute.how can l solve this problem and l m using
Python 3.5 and Python 2.7

and also l downloaded
Python Scripting with ERDAS IMAGINE Spatial Modeler 2014
and example python Scripts do not works due to missing attribute
.l hope l can find an answer for this question.

Answer Source

Indeed, imagine has no member modeler. But that is the module you have installed from PyPI.

If you want to do Python Scripting with ERDAS IMAGINE Spatial Modeler, you should try what it says in the documentation:

For reference, the ERDAS IMAGINE Python libraries are installed in: $IMAGINE_HOME\usr\lib\Win32Release\python