I have ArcGIS Pro 3.0, window task scheduler and python 27. I am not expertise with window task scheduler. Please see screenshots and error below. It is working successful when I run python script manually. But when I tried to run window task scheduler, I got error messages. I am not sure what to do. Please kindly assist. Thank you so much in advance.


ERROR MESSAGES




PYTHON SCRIPT CODE
import arcpy
import csv
import os
from datetime import date
from datetime import datetime
matchTableName = r"ElevationCertificatesAttachmentMatchTable.csv"
docFolder = r"Q:\2023\IMPORTED TO GIS"
matchField = "MatchID"
pathField = "Filename"
#change this date to the disired value
processFilesAddedOnDate = date.today()
# iterate through each .pdf file in the directory and write a row to the table
for (root, dirs, files) in os.walk(docFolder):
workingFolder = root
matchTableNamePath = os.path.join(root, matchTableName)
# create a new Match Table csv file
if os.path.exists(matchTableNamePath):
os.remove(matchTableNamePath)
writer = csv.writer(open(matchTableNamePath, "w", newline=''), delimiter=",")
# write a header row (the table will have two columns: ParcelID and Picture)
writer.writerow([matchField, pathField, 'fullPath'])
for f in files:
if '.pdf' in f:
#if datetime.strptime(os.path.getctime(os.path.join(root, f)),"%m/%d/%Y") >= processFilesAddedOnDate:
if date.fromtimestamp(os.path.getctime(os.path.join(root, f))) >= processFilesAddedOnDate:
#print(processFilesAddedOnDate)
#print(date.fromtimestamp(os.path.getctime(os.path.join(root, f))))
fileNameToAddress = f.replace(".pdf", "")
fileNameToAddress = fileNameToAddress.replace(" ", " ");
fileNameToAddress = fileNameToAddress.replace("nw", "NW")
try:
firstPartUntilNW = fileNameToAddress.split("NW")[0].strip().split(" ")
restAfterNW = fileNameToAddress.split("NW")[1].strip()
#print(firstPartUntilNW, len(firstPartUntilNW))
#print(restAfterNW)
fileNameToAddressWithNoPermitNumber = ""
if len(firstPartUntilNW) == 2:
fileNameToAddressWithNoPermitNumber = firstPartUntilNW[1]+" NW "+restAfterNW
if len(firstPartUntilNW)== 1:
fileNameToAddressWithNoPermitNumber = firstPartUntilNW[0]+" NW "+restAfterNW
#print(fileNameToAddressWithNoPermitNumber)
writer.writerow((fileNameToAddressWithNoPermitNumber,f, os.path.join(root, f)))
except:
continue
del writer
# Set the workspace environment and run add attachment
arcpy.env.workspace = r'C:\Users\AppData\Roaming\Esri\ArcGISPro\Favorites\test.sde'
arcpy.management.AddAttachments('sde.TEST.TEST', 'ADDR', matchTableNamePath, "MatchID", "Filename", workingFolder)