<?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: arcmap 10.8.1 upgrade broke python scripts in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/arcmap-10-8-1-upgrade-broke-python-scripts/m-p/1111285#M62784</link>
    <description>&lt;P&gt;Do you have ArcGIS Pro installed on the same machine?&lt;/P&gt;</description>
    <pubDate>Tue, 26 Oct 2021 15:29:07 GMT</pubDate>
    <dc:creator>BillFox</dc:creator>
    <dc:date>2021-10-26T15:29:07Z</dc:date>
    <item>
      <title>arcmap 10.8.1 upgrade broke python scripts</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-10-8-1-upgrade-broke-python-scripts/m-p/1111275#M62783</link>
      <description>&lt;P&gt;updated a machine used for nightly processing from 10.7.1 to 10.8.1. Now I am having issues where I am getting a syntax error on a CalculateField with a function and returns&amp;nbsp;ERROR 000989: Python syntax error: Parsing error SyntaxError: invalid syntax (line 1)&lt;/P&gt;&lt;P&gt;This is the line I have been using for a couple years with no issues.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;arcpy.management.CalculateField(finalTable, "SiteAddress", "myFun(!LocationStartNumber!,!StreetDirection!,!StreetName!,!StreetWay!,!UnitNumber!)", "PYTHON_9.3", "def myFun(LocationStartNumber,StreetDirection,StreetName,StreetWay,UnitNumber):\\n  if UnitNumber is None:\\n    UnitNumber = ''\\n  if LocationStartNumber == 0:\\n    if StreetName == 'TBD':\\n      return StreetName \\n    else:\\n      val = '{} {} {} {}'.format(StreetDirection,StreetName,StreetWay,UnitNumber)\\n      return val.strip()\\n  else:\\n    return '{} {} {} {} {}'.format(LocationStartNumber,StreetDirection,StreetName,StreetWay,UnitNumber)\\n")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I took the calculate out of the script and run it in ArcMap for now. But not a long term solution. What is going on?&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;</description>
      <pubDate>Tue, 26 Oct 2021 15:17:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-10-8-1-upgrade-broke-python-scripts/m-p/1111275#M62783</guid>
      <dc:creator>MichaelKohler</dc:creator>
      <dc:date>2021-10-26T15:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: arcmap 10.8.1 upgrade broke python scripts</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-10-8-1-upgrade-broke-python-scripts/m-p/1111285#M62784</link>
      <description>&lt;P&gt;Do you have ArcGIS Pro installed on the same machine?&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 15:29:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-10-8-1-upgrade-broke-python-scripts/m-p/1111285#M62784</guid>
      <dc:creator>BillFox</dc:creator>
      <dc:date>2021-10-26T15:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: arcmap 10.8.1 upgrade broke python scripts</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-10-8-1-upgrade-broke-python-scripts/m-p/1111288#M62785</link>
      <description>&lt;P&gt;yes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I use a Task Manager to start the script and explicitly state the path to the python exe I want to use. Also, I have both pro and desktop python environments in my Visual Studio and activate them as needed during development.&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 15:57:00 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-10-8-1-upgrade-broke-python-scripts/m-p/1111288#M62785</guid>
      <dc:creator>MichaelKohler</dc:creator>
      <dc:date>2021-10-26T15:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: arcmap 10.8.1 upgrade broke python scripts</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-10-8-1-upgrade-broke-python-scripts/m-p/1111310#M62787</link>
      <description>&lt;P&gt;That code block is terribly difficult to interpret being all on one line like that. Try making a &lt;A href="https://www.w3schools.com/python/gloss_python_multi_line_strings.asp" target="_self"&gt;multiline string&lt;/A&gt; with three single quotes for the code block.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;myFun_def = '''def myFun(LocationStartNumber,StreetDirection,StreetName,StreetWay,UnitNumber):
  if UnitNumber is None:
    UnitNumber = ''
  if LocationStartNumber == 0:
    if StreetName == 'TBD':
      return StreetName
    else:
      val = '{} {} {} {}'.format(StreetDirection,StreetName,StreetWay,UnitNumber)
      return val.strip()
  else:
    return '{} {} {} {} {}'.format(LocationStartNumber,StreetDirection,StreetName,StreetWay,UnitNumber)
'''
arcpy.management.CalculateField(
    in_table=finalTable,
    field="SiteAddress",
    expression="myFun(!LocationStartNumber!,!StreetDirection!,!StreetName!,!StreetWay!,!UnitNumber!)",
    expression_type="PYTHON_9.3",
    code_block=myFun_def
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 16:08:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-10-8-1-upgrade-broke-python-scripts/m-p/1111310#M62787</guid>
      <dc:creator>BlakeTerhune</dc:creator>
      <dc:date>2021-10-26T16:08:34Z</dc:date>
    </item>
    <item>
      <title>Re: arcmap 10.8.1 upgrade broke python scripts</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-10-8-1-upgrade-broke-python-scripts/m-p/1111320#M62788</link>
      <description>&lt;P&gt;I'm curious if its the "PYTHON_9.3" causing the issue.&amp;nbsp; Maybe try just '&lt;SPAN&gt;PYTHON3'.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;What python are you using? 2.7 or 3?&amp;nbsp; I think the arcpy.management.CalculateField dot style of syntax is exclusive to 3, and 3 doesn't use PYTHON_9.3 as an expression type parameter.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 16:33:35 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-10-8-1-upgrade-broke-python-scripts/m-p/1111320#M62788</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2021-10-26T16:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: arcmap 10.8.1 upgrade broke python scripts</title>
      <link>https://community.esri.com/t5/python-questions/arcmap-10-8-1-upgrade-broke-python-scripts/m-p/1111333#M62790</link>
      <description>&lt;P&gt;I had is formatted that way to reduce the number of lines I had to look at. But I guess the 10.8.1 python didn't like the way I formatted the function.&lt;/P&gt;&lt;P&gt;I had tried it using "" + \&amp;nbsp; to format but that came out formatted as a single line as well. The triple quotes did the trick. I think I'm going to eventually write files with the functions and read them from there.&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 26 Oct 2021 16:51:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/arcmap-10-8-1-upgrade-broke-python-scripts/m-p/1111333#M62790</guid>
      <dc:creator>MichaelKohler</dc:creator>
      <dc:date>2021-10-26T16:51:11Z</dc:date>
    </item>
  </channel>
</rss>

