king9742 2020-05-21 12:40 采纳率: 0%
浏览 112
已结题

arcpy.Describe()函数在新线程中报错怎么解决?

开发的项目中需要在新线程中判断一条路径的工作空间类型为文件夹还是gdb数据库,但是arcpy.Describe()函数在新线程中报错。特来求助!代码示例如下:

# -*- coding: utf-8 -*-
import arcpy
import threading

wkpath = "F:/Desktop/data.gdb"

def pathtype():
    desc = arcpy.Describe(wkpath)
    print("工作目录类型为:" + desc.workspaceType)

def thread_it(func, *args):
    t = threading.Thread(target = func, args = args) 
    t.setDaemon(False)
    t.start()

thread_it(pathtype)

这个目录是真实存在的,但报错说这个目录不存在:

Exception in thread Thread-1:
Traceback (most recent call last):
  File "C:\Python27\ArcGIS10.7\lib\threading.py", line 801, in __bootstrap_inner
 Custom Domain by Bitly()
  File "C:\Python27\ArcGIS10.7\lib\threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "F:\Desktop\test2.py", line 9, in pathtype
    desc = arcpy.Describe(wkpath)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.7\ArcPy\arcpy\__init__.py", line 1260, in Describe
    return gp.describe(value, data_type)
  File "C:\Program Files (x86)\ArcGIS\Desktop10.7\ArcPy\arcpy\geoprocessing\_base.py", line 376, in describe
    self._gp.Describe(*gp_fixargs(args, True)))
IOError: "F:/Desktop/data.gdb" does not exist
  • 写回答

3条回答 默认 最新

  • 天际的海浪 2020-05-21 14:39
    关注

    改成 \ 试试

    wkpath = r"F:\Desktop\data.gdb"


    评论

报告相同问题?

悬赏问题

  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端
  • ¥15 基于PLC的三轴机械手程序
  • ¥15 多址通信方式的抗噪声性能和系统容量对比