假设模块没有建模器attribu

2024-06-16 11:32:41 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用Python执行layerstack操作。但是,我遇到了一个错误。在

下面是示例代码:

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)
m.Execute()
print “\nCreating MS image using bands 1-7…”

我在from imagine import modeler期间出错,错误在这里:

^{pr2}$

我安装了pip install imagine,但在imaging模块中没有建模器属性。如何我能用Python 3.5 and Python 2.7来解决这个问题吗 我还下载了Python Scripting with ERDAS IMAGINE Spatial Modeler 2014,示例python脚本由于缺少属性modeler而无法工作,希望我能找到这个问题的答案。在


Tags: pathfromimport示例错误imaginemodelertif
2条回答

pip install imagine没有安装您想要的。相反,它使用了this,这是Google图像搜索库的包装,它没有“modeler”。在

您需要做的是阅读this,特别是“配置Python以使用spatialmodeler”部分(就在“简介”之后)。它包含了如何使用Python配置该工具的完整描述。在

另外,正如您在那里看到的-python3.x不支持,只支持2.7行。在

事实上,imaginehas no member ^{}。但这是您从PyPI安装的模块。在

如果您想做Python Scripting with ERDAS IMAGINE Spatial Modeler,您应该尝试一下文档中的内容:

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

相关问题 更多 >