<?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: Syntax error in python code exported from ModelBuilder in PRO for arcpy.EnvManager in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/syntax-error-in-python-code-exported-from/m-p/1227717#M65992</link>
    <description>&lt;P&gt;Check your paths, and simplify the spatial reference&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
sr = arcpy.SpatialReference(2926)
# sr.name 'NAD_1983_HARN_StatePlane_Washington_North_FIPS_4601_Feet'
with arcpy.EnvManager(
    outputCoordinateSystem=sr.name,
    preserveGlobalIds=True,
    scratchWorkspace=r"....gdb",
    workspace=r"....gdb"):&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 01 Nov 2022 22:41:02 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2022-11-01T22:41:02Z</dc:date>
    <item>
      <title>Syntax error in python code exported from ModelBuilder in PRO for arcpy.EnvManager</title>
      <link>https://community.esri.com/t5/python-questions/syntax-error-in-python-code-exported-from/m-p/1227707#M65990</link>
      <description>&lt;P&gt;I created a ModelBuilder routine and exported it to Python, so that I could add some custom code in the middle.&lt;/P&gt;&lt;P&gt;When I try to run the script, it stops with a syntax error in the final statement, pointing to the scratch workspace file geodatabase.&lt;/P&gt;&lt;P&gt;Any ideas on what I can fix?&amp;nbsp; I can't see the problem.&amp;nbsp; Thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy

def ScheduledTaskMilepostsNeedsPythonPRO():  # Scheduled Task Mileposts Needs Python PRO

&amp;lt; my code &amp;gt;

if __name__ == '__main__':
    # Global Environment settings
    #  workspace=r"\\spokanecounty.org\publicworks\GIS\WorkShop\xArcGISProTasks\WorkRoadSegments.gdb"):
    with arcpy.EnvManager(outputCoordinateSystem="PROJCS["NAD_1983_HARN_StatePlane_Washington_North_FIPS_4601_Feet",GEOGCS["GCS_North_American_1983_HARN",DATUM["D_North_American_1983_HARN",SPHEROID["GRS_1980",6378137.0,298.257222101]],PRIMEM["Greenwich",0.0],UNIT["Degree",0.0174532925199433]],PROJECTION["Lambert_Conformal_Conic"],PARAMETER["False_Easting",1640416.666666667],PARAMETER["False_Northing",0.0],PARAMETER["Central_Meridian",-120.8333333333333],PARAMETER["Standard_Parallel_1",47.5],PARAMETER["Standard_Parallel_2",48.73333333333333],PARAMETER["Latitude_Of_Origin",47.0],UNIT["Foot_US",0.3048006096012192]]", preserveGlobalIds=True, scratchWorkspace=r"\\mynetworklocation\xArcGISProTasks\WorkRoadSegments.gdb\",
                          workspace=r"\\mynetworklocation\xArcGISProTasks\WorkRoadSegments.gdb\"):
        ScheduledTaskMilepostsNeedsPythonPRO()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Nov 2022 22:01:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-error-in-python-code-exported-from/m-p/1227707#M65990</guid>
      <dc:creator>LoriMcCormack1</dc:creator>
      <dc:date>2022-11-01T22:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in python code exported from ModelBuilder in PRO for arcpy.EnvManager</title>
      <link>https://community.esri.com/t5/python-questions/syntax-error-in-python-code-exported-from/m-p/1227717#M65992</link>
      <description>&lt;P&gt;Check your paths, and simplify the spatial reference&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
sr = arcpy.SpatialReference(2926)
# sr.name 'NAD_1983_HARN_StatePlane_Washington_North_FIPS_4601_Feet'
with arcpy.EnvManager(
    outputCoordinateSystem=sr.name,
    preserveGlobalIds=True,
    scratchWorkspace=r"....gdb",
    workspace=r"....gdb"):&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 01 Nov 2022 22:41:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-error-in-python-code-exported-from/m-p/1227717#M65992</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-11-01T22:41:02Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in python code exported from ModelBuilder in PRO for arcpy.EnvManager</title>
      <link>https://community.esri.com/t5/python-questions/syntax-error-in-python-code-exported-from/m-p/1227756#M65995</link>
      <description>&lt;P&gt;Three problems:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;scratchWorkspace=r"\\mynetworklocation\xArcGISProTasks\WorkRoadSegments.gdb\",&lt;/FONT&gt;&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;workspace=r"\\mynetworklocation\xArcGISProTasks\WorkRoadSegments.gdb\"&lt;/FONT&gt;&amp;nbsp;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Python raw strings &lt;FONT face="courier new,courier"&gt;r"\\some\string"&lt;/FONT&gt; can't end in a single backslash, i.e.&amp;nbsp;&lt;FONT face="courier new,courier"&gt;r"\\some\string\"&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="https://stackoverflow.com/questions/647769/why-cant-pythons-raw-string-literals-end-with-a-single-backslash" target="_self"&gt;Why can't Python's raw string literals end with a single backslash?&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; 3. Your spatial reference is invalid as it is wrapped in double quotes&amp;nbsp;&lt;EM&gt;and&lt;/EM&gt; contains&amp;nbsp;embedded double quotes.&lt;/P&gt;&lt;P&gt;Either do what &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/215600"&gt;@DanPatterson&lt;/a&gt;&amp;nbsp;suggests, using the factory code (2926) to create a SpatialReference object (which I recommend), or wrap the spatial reference string in single quotes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;And next time, &lt;SPAN&gt;include the full error message,&amp;nbsp;&lt;/SPAN&gt;please don't just say "&lt;SPAN&gt;a syntax error". You're removing valuable information that can help others help you.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Nov 2022 06:30:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-error-in-python-code-exported-from/m-p/1227756#M65995</guid>
      <dc:creator>Luke_Pinner</dc:creator>
      <dc:date>2022-11-02T06:30:40Z</dc:date>
    </item>
    <item>
      <title>Re: Syntax error in python code exported from ModelBuilder in PRO for arcpy.EnvManager</title>
      <link>https://community.esri.com/t5/python-questions/syntax-error-in-python-code-exported-from/m-p/1227968#M66001</link>
      <description>&lt;P&gt;Hey, Dan,&lt;/P&gt;&lt;P&gt;What an honor to get a reply from you.&amp;nbsp; I used your ArcIMS code years ago.&amp;nbsp; You're a legend.&lt;/P&gt;&lt;P&gt;I was able to get both options to work that Dan and Luke described above, with one correction.&lt;/P&gt;&lt;P&gt;I created SpatialReference object and using it in my EnvManager statement, and I got it to work once I changed outputCoordinateSystem=sr.name to outputCoordinateSystem=sr.&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy
sr = arcpy.SpatialReference(2926)
# sr.name is 'NAD_1983_HARN_StatePlane_Washington_North_FIPS_4601_Feet'

def ScheduledTaskMilepostsNeedsPythonPRO():  # Scheduled Task Mileposts Needs Python PRO
&amp;lt;my code&amp;gt;
if __name__ == '__main__':
    # Global Environment settings
    with arcpy.EnvManager(outputCoordinateSystem=sr, preserveGlobalIds=True, scratchWorkspace=r"\\mynetworklocation\WorkRoadSegments.gdb",
                          workspace=r"\\mynetworklocation\WorkRoadSegments.gdb"):
        ScheduledTaskMilepostsNeedsPythonPRO()
&lt;/LI-CODE&gt;&lt;P&gt;I did what Luke mentioned by removing the double double quotes, and removing the ending \ in my two work space paths.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;import arcpy

def ScheduledTaskMilepostsNeedsPythonPRO():  # Scheduled Task Mileposts Needs Python PRO

&amp;lt;my code&amp;gt;

if __name__ == '__main__':
    # Global Environment settings
    #  workspace=r"\\spokanecounty.org\publicworks\GIS\WorkShop\xArcGISProTasks\WorkRoadSegments.gdb"):
    with arcpy.EnvManager(outputCoordinateSystem="PROJCS['NAD_1983_HARN_StatePlane_Washington_North_FIPS_4601_Feet',GEOGCS['GCS_North_American_1983_HARN',DATUM['D_North_American_1983_HARN',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting',1640416.666666667],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-120.8333333333333],PARAMETER['Standard_Parallel_1',47.5],PARAMETER['Standard_Parallel_2',48.73333333333333],PARAMETER['Latitude_Of_Origin',47.0],UNIT['Foot_US',0.3048006096012192]]", preserveGlobalIds=True, scratchWorkspace=r"\\mynetworklocation\WorkRoadSegments.gdb",
                          workspace=r"\\mynetworklocation\WorkRoadSegments.gdb"):
        ScheduledTaskMilepostsNeedsPythonPRO()&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 02 Nov 2022 16:04:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/syntax-error-in-python-code-exported-from/m-p/1227968#M66001</guid>
      <dc:creator>LoriMcCormack1</dc:creator>
      <dc:date>2022-11-02T16:04:19Z</dc:date>
    </item>
  </channel>
</rss>

