<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Got Error when ran python - Exported from ArcGIS Pro Notebook to Python Script in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/got-error-when-ran-python-exported-from-arcgis-pro/m-p/1257146#M66827</link>
    <description>&lt;P&gt;try providing the full path to sde.GIS.test on line 53&lt;/P&gt;</description>
    <pubDate>Fri, 10 Feb 2023 18:15:56 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2023-02-10T18:15:56Z</dc:date>
    <item>
      <title>Got Error when ran python - Exported from ArcGIS Pro Notebook to Python Script</title>
      <link>https://community.esri.com/t5/python-questions/got-error-when-ran-python-exported-from-arcgis-pro/m-p/1257135#M66826</link>
      <description>&lt;P&gt;Hello all,&lt;/P&gt;&lt;P&gt;I have ArcGIS Pro 3.0 notebook and python 27. I am not expertise with code. Please see error and code below. I exported from ArcGIS Pro notebook to Python script. It is working fine when run on ArcGIS Pro notebook. But when I tried to run Python script, I got an error message. I am not sure what to do. Please kindly assist. Thank you so much in advance.&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;PYTHON SCRIPT CODE&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from arcgis.gis import GIS
import arcpy
import csv
import os
from datetime import date
from datetime import datetime

matchTableName = r"CertificatesAttachmentMatchTable.csv"
docFolder = r"Q:\2022\IMPORTED TO GIS"

matchField = "MatchID"
pathField = "Filename" 

#change this date to the disired value
processFilesAddedOnDate = datetime. strptime('06/01/2022', '%m/%d/%Y')
#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.fromtimestamp(os.path.getctime(os.path.join(root, f))).strftime("%m/%d/%Y") &amp;gt;= processFilesAddedOnDate.strftime("%m/%d/%Y") :
                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
    arcpy.management.AddAttachments("sde.123.test", "ADDR", matchTableNamePath, "MatchID", "Filename", workingFolder)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;U&gt;&lt;STRONG&gt;ERROR MESSAGE&lt;/STRONG&gt;&lt;/U&gt;&lt;/P&gt;&lt;P&gt;= RESTART: M:\test\ArcGIS\Projects\EC\IMPORTEC.py&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "M:\test\ArcGIS\Projects\EC\IMPORTEC.py", line 52, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;arcpy.management.AddAttachments("sde.123.test", "ADDR", matchTableNamePath, "MatchID", "Filename", workingFolder)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 874, in AddAttachments&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;raise e&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\management.py", line 871, in AddAttachments&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;retval = convertArcObjectToPythonObject(gp.AddAttachments_management(*gp_fixargs((in_dataset, in_join_field, in_match_table, in_match_join_field, in_match_path_field, in_working_folder), True)))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py", line 512, in &amp;lt;lambda&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;return lambda *args: val(*gp_fixargs(args, True))&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;arcgisscripting.ExecuteError: Failed to execute. Parameters are not valid.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ERROR 000732: Input Dataset: Dataset sde.123.test does not exist or is not supported&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Failed to execute (AddAttachments).&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 21:13:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/got-error-when-ran-python-exported-from-arcgis-pro/m-p/1257135#M66826</guid>
      <dc:creator>AlexP_</dc:creator>
      <dc:date>2023-02-24T21:13:02Z</dc:date>
    </item>
    <item>
      <title>Re: Got Error when ran python - Exported from ArcGIS Pro Notebook to Python Script</title>
      <link>https://community.esri.com/t5/python-questions/got-error-when-ran-python-exported-from-arcgis-pro/m-p/1257146#M66827</link>
      <description>&lt;P&gt;try providing the full path to sde.GIS.test on line 53&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 18:15:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/got-error-when-ran-python-exported-from-arcgis-pro/m-p/1257146#M66827</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-02-10T18:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Got Error when ran python - Exported from ArcGIS Pro Notebook to Python Script</title>
      <link>https://community.esri.com/t5/python-questions/got-error-when-ran-python-exported-from-arcgis-pro/m-p/1257155#M66828</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;&amp;nbsp; Thank you for your prompt response. I ran it again and I got another error message below. I don't think I wrote the fullpath correctly.&lt;/P&gt;&lt;P&gt;I am trying to set up using python scrip to set up in task scheduler. is it possible to set up ArcGIS Pro Notebook to window task scheduler? the goal is to have it run by task scheduler. Please kindly advise.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;= RESTART: &lt;SPAN&gt;M:\test\ArcGIS\Projects\EC\IMPORTEC.py&lt;/SPAN&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Traceback (most recent call last):&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;File "&lt;SPAN&gt;M:\test\ArcGIS\Projects\EC\IMPORTEC.py&lt;/SPAN&gt;", line 53, in &amp;lt;module&amp;gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;arcpy.management.AddAttachments(r"C:\Users\AppData\Roaming\Esri\ArcGISPro\Favorites\test.sde", "sde.123.test", "ADDR", matchTableNamePath, "MatchID", "Filename", workingFolder)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;TypeError: AddAttachments() takes from 0 to 6 positional arguments but 7 were given&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&amp;gt;&amp;gt;&amp;gt; &lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Feb 2023 21:13:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/got-error-when-ran-python-exported-from-arcgis-pro/m-p/1257155#M66828</guid>
      <dc:creator>AlexP_</dc:creator>
      <dc:date>2023-02-24T21:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Got Error when ran python - Exported from ArcGIS Pro Notebook to Python Script</title>
      <link>https://community.esri.com/t5/python-questions/got-error-when-ran-python-exported-from-arcgis-pro/m-p/1257251#M66830</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/add-attachments.htm" target="_blank"&gt;Add Attachments (Data Management)—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;P&gt;The error is specific&lt;/P&gt;&lt;P&gt;arcpy.management.AddAttachments(in_dataset, in_join_field, in_match_table, in_match_join_field, in_match_path_field, {in_working_folder})&lt;/P&gt;&lt;P&gt;6 parameters, the first 5 required and the last optional.... check your inputs to the tool.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 10 Feb 2023 22:06:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/got-error-when-ran-python-exported-from-arcgis-pro/m-p/1257251#M66830</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-02-10T22:06:33Z</dc:date>
    </item>
    <item>
      <title>Re: Got Error when ran python - Exported from ArcGIS Pro Notebook to Python Script</title>
      <link>https://community.esri.com/t5/python-questions/got-error-when-ran-python-exported-from-arcgis-pro/m-p/1258664#M66855</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;&amp;nbsp; Thank you for the information. I tried this method and it doesn't work. I found a different method for sde file workspace location added above line "acrpy.management.addattachments" and it was successful.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;# Set the workspace environment and run add attachment
    arcpy.env.workspace = r'C:\Users\AppData\Roaming\Esri\ArcGISPro\Favorites\test.sde'&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Feb 2023 20:21:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/got-error-when-ran-python-exported-from-arcgis-pro/m-p/1258664#M66855</guid>
      <dc:creator>AlexP_</dc:creator>
      <dc:date>2023-02-15T20:21:33Z</dc:date>
    </item>
  </channel>
</rss>

