【发布时间】:2014-11-19 09:33:28
【问题描述】:
我有一个 ArcPy 脚本,它在 IDLE 中运行时可以工作,但在作为计划任务运行时会失败。这是问题部分:
outPath = os.path.abspath(r"X:\GroupDirs\0731\GIS_CORE\PUPS")
log.write("Output path: {}\n".format(outPath))
try:
outDir = os.path.join(outPath, "utiliquest{}".format(date))
if not os.path.exists(outDir):
os.makedirs(outDir)
log.write("Created scratch and output")
except:
fail_log(log)
当我在 IDLE 中运行它时,它会正确输出、创建目录并继续执行。
Output path: X:\GroupDirs\0731\GIS_CORE\PUPS
Created scratch and output
当它作为计划任务运行时,日志文件有正确的目录,但os.makedirs(outDir) 命令执行失败:
Output path: X:\GroupDirs\0731\GIS_CORE\PUPS
Failed at 09/24/14 14:41:45
PYTHON ERRORS:
Traceback info:
File "C:\Batch Processes\IRTHnet\Batch_CopyData.py", line 64, in <module>
os.makedirs(outDir)
Error Info:
[Error 3] The system cannot find the path specified: 'X:\\'
每次都在同一台机器上运行,所以 X 驱动器指向同一个位置。
为什么这会导致失败,我可以做些什么来修复/规避?
【问题讨论】: