【问题标题】:Perfectly running python script gives error when run from web.py从 web.py 运行时,完美运行 python 脚本会出错
【发布时间】:2011-10-04 23:51:25
【问题描述】:

我有以下 python 脚本,如果单独运行,可以完美运行:

import arcpy 

val = arcpy.GetCellValue_management("D:\dem-merged\lidar_wsg84", "-95.090174910630012 29.973962146120652", "")
print str(val)

我想将其公开为 Web 服务,因此我安装了 web.py 并为 code.py 编写了以下代码。但它给出了错误(调用时。编译正常)。

import web
import arcpy        
urls = (
    '/(.*)', 'hello'
)
app = web.application(urls, globals())

class hello:        
    def GET(self, name):

        val = arcpy.GetCellValue_management("D:\dem-merged\lidar_wsg84", "-95.090174910630012 29.973962146120652", "")
        return  str(val)

if __name__ == "__main__":
    app.run()

当我使用http://localhost:8080 调用它时,我收到以下错误:

<class 'arcgisscripting.ExecuteError'> at /
ERROR 000582: Error occurred during execution.

Python  C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\management.py in GetCellValue, line 8460
Web GET http://localhost:8080/
Traceback (innermost first)

C:\Program Files (x86)\ArcGIS\Desktop10.0\arcpy\arcpy\management.py in GetCellValue
          be returned."""
    try:

        retval = convertArcObjectToPythonObject(gp.GetCellValue_management(*gp_fixargs((in_raster, location_point, band_index), True)))
        return retval
    except Exception, e:
        raise e ...
@gptooldoc('GetRasterProperties_management', None)
def GetRasterProperties(in_raster=None, property_type=None):
    """GetRasterProperties_management(in_raster, {property_type})
        Returns the properties of a raster dataset.

我尝试过以多种方式对其进行调试,如果我只返回“hello”,代码 .py 运行良好。我使用的库是 ArcGIS 地理处理工具箱库。

关于可能出现什么问题的任何想法?

【问题讨论】:

  • 通过web.py 运行时是否以其他用户身份运行?权限可能是问题。

标签: python arcgis web.py


【解决方案1】:

这看起来像是来自第三方模块的错误。尝试找出错误代码 (000582) 对应用程序的实际含义。

【讨论】:

    最近更新 更多