【发布时间】:2019-11-02 19:14:51
【问题描述】:
我有一个使用 arcpy 模型的 ArcGIS 脚本。我想将它与 Django 结合起来。该脚本在控制台上成功运行,但是,当使用 Django 运行时,我发现 arcpy 函数没有运行。所以我对它做了一个简单的测试,得到了同样的结果。
test.py
import arcpy
import os
def test_arcpy():
tempFolder = arcpy.env.scratchFolder
tempGDBPath = os.path.join(tempFolder, 'test.gdb')
arcpy.env.overwriteOutput = True
if not arcpy.Exists(tempGDBPath):
arcpy.AddMessage('create..')
arcpy.CreateFileGDB_management(tempFolder, 'test.gdb')
return arcpy.Exists(tempGDBPath)
views.py
from django.http import HttpResponse
from . import test
def t(request):
msg = str(test.test_arcpy())
return HttpResponse(msg)
如果我在控制台中运行 test.py,它返回 True。但如果我在 django 中运行它,它总是返回 false。如果我不能解决它,我就不能在 django 中制作更难的脚本。你能帮助我吗? 我在Flask app with ArcGIS, Arcpy does not run找到了类似的问题,但是这个问题没有解决方案。
【问题讨论】: