RuntimeError: cannot open 'D:\work\data\temp\test.shp'

严修谨
2023-12-01
#coding:utf8
import arcpy

path=r'D:\work\data\temp\test.shp'



with arcpy.da.SearchCursor(path,'FID') as rows:
    print rows



上述代码报错:

Traceback (most recent call last):
File "D:/temp/test.py", line 11, in <module>
with arcpy.da.SearchCursor(path,'FID') as rows:
RuntimeError: cannot open 'D:\work\data\temp\test.shp'

没找到原因,但是在这句之前如果设置了arcpy.env.workspace  或者执行了与文件路径相关的arcpy的函数之后就不报错了。

转载于:https://www.cnblogs.com/z964166725/p/11138754.html

 类似资料: