<?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: OSError when using arcpy.mp.ArcGISProject() in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/oserror-when-using-arcpy-mp-arcgisproject/m-p/1193223#M6302</link>
    <description>&lt;P&gt;might be the case, but you could check by throwing in an arcpy.AddMessage and/or print statement after getting it... perhaps&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;print(aprx.filePath)&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 18 Jul 2022 22:56:34 GMT</pubDate>
    <dc:creator>DanPatterson</dc:creator>
    <dc:date>2022-07-18T22:56:34Z</dc:date>
    <item>
      <title>OSError when using arcpy.mp.ArcGISProject()</title>
      <link>https://community.esri.com/t5/developers-questions/oserror-when-using-arcpy-mp-arcgisproject/m-p/1193154#M6299</link>
      <description>&lt;P&gt;I am trying to zoom into a selected polygon as part of code for a custom print tool within AppBuilder.&amp;nbsp;Below is my code. However, I am having trouble getting it to zoom into the selected polygon. I have ran into various errors, but the current error is below. Any ideas for resolving this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Code:&lt;/P&gt;&lt;P&gt;# Part 3: Zoom into selected polygon&lt;/P&gt;&lt;P&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;/P&gt;&lt;P&gt;# trying to zoom into sltPoly&lt;BR /&gt;mv = aprx.activeView # mapview&lt;BR /&gt;m = mv.map # map&lt;BR /&gt;lay = m.listLayers(sltPoly)&lt;BR /&gt;sltLyr = m.listLayers()[3]&lt;BR /&gt;for g in m.listLayers():&lt;BR /&gt;&amp;nbsp; &amp;nbsp; print("Layer: {0} Layers".format(g.name))&lt;BR /&gt;lyrExt = mv.getLayerExtent(sltLyr)&lt;BR /&gt;mv.camera.setExtent(lyrExt)&lt;BR /&gt;df.scale = 6000&lt;BR /&gt;arcpy.SelectLayerByAttribute_management(sltPoly, "CLEAR_SELECTION")&lt;BR /&gt;arcpy.Near_analysis(points_lyr, sltPoly)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error (redacting was my own):&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Error executing tool. Export Web Map : Traceback (most recent call last): File "**redacted**\dynamicprintservice\ExportWebMap.py", line 211, in &amp;lt;module&amp;gt; aprx = arcpy.mp.ArcGISProject("CURRENT") File "c:\program files\arcgis\server\framework\runtime\arcgis\Resources\arcpy\arcpy\_mp.py", line 337, in __init__ self._arc_object = arcgisscripting._mapping.ArcGISProject(*gp_fixargs((aprx_path,), True)) OSError: CURRENT Failed to execute (Export Web Map). Failed to execute (Export Web Map).&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 20:10:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/oserror-when-using-arcpy-mp-arcgisproject/m-p/1193154#M6299</guid>
      <dc:creator>MM598</dc:creator>
      <dc:date>2022-07-18T20:10:57Z</dc:date>
    </item>
    <item>
      <title>Re: OSError when using arcpy.mp.ArcGISProject()</title>
      <link>https://community.esri.com/t5/developers-questions/oserror-when-using-arcpy-mp-arcgisproject/m-p/1193162#M6300</link>
      <description>&lt;P&gt;related&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/developers-questions/why-does-arcpy-mp-arcgisproject-give-an-oserror/td-p/557489" target="_blank"&gt;Solved: Why does arcpy.mp.ArcGISProject() give an OSError? - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;CURRENT can only be used from an open project and python being able to see the project (eg a custom or python tool in a toolbox, or the python IDE etc)&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 20:30:15 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/oserror-when-using-arcpy-mp-arcgisproject/m-p/1193162#M6300</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-07-18T20:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: OSError when using arcpy.mp.ArcGISProject()</title>
      <link>https://community.esri.com/t5/developers-questions/oserror-when-using-arcpy-mp-arcgisproject/m-p/1193169#M6301</link>
      <description>&lt;P&gt;I did come across that thread, but it did not seem related because I am not referring to a toolbox as this user was in their code.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I actually am running the tool within an app with an open map via a print tool, so python "seeing" the project should not be a problem.&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 20:36:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/oserror-when-using-arcpy-mp-arcgisproject/m-p/1193169#M6301</guid>
      <dc:creator>MM598</dc:creator>
      <dc:date>2022-07-18T20:36:52Z</dc:date>
    </item>
    <item>
      <title>Re: OSError when using arcpy.mp.ArcGISProject()</title>
      <link>https://community.esri.com/t5/developers-questions/oserror-when-using-arcpy-mp-arcgisproject/m-p/1193223#M6302</link>
      <description>&lt;P&gt;might be the case, but you could check by throwing in an arcpy.AddMessage and/or print statement after getting it... perhaps&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;aprx = arcpy.mp.ArcGISProject("CURRENT")&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;print(aprx.filePath)&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Jul 2022 22:56:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/oserror-when-using-arcpy-mp-arcgisproject/m-p/1193223#M6302</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2022-07-18T22:56:34Z</dc:date>
    </item>
    <item>
      <title>Re: OSError when using arcpy.mp.ArcGISProject()</title>
      <link>https://community.esri.com/t5/developers-questions/oserror-when-using-arcpy-mp-arcgisproject/m-p/1213375#M6357</link>
      <description>&lt;P&gt;related&lt;/P&gt;&lt;P&gt;I too am having problems with&amp;nbsp;&lt;FONT face="courier new,courier"&gt;arcpy.mp.ArcGISProject("CURRENT")&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;As part of my code I use&amp;nbsp;&lt;FONT face="courier new,courier"&gt;arcpy.mp.ArcGISProject("CURRENT")&lt;/FONT&gt;&amp;nbsp;to detect whether a script is running within ArcGIS Pro or outside (i.e. from IDE or scheduled task).&amp;nbsp; I notice that occasionally&amp;nbsp; &lt;FONT face="courier new,courier"&gt;arcpy.mp.ArcGISProject("CURRENT")&lt;/FONT&gt;&amp;nbsp; throws an &lt;FONT face="courier new,courier"&gt;OSError&lt;/FONT&gt;&amp;nbsp; which is caught by a &lt;FONT face="courier new,courier"&gt;try ... except&lt;/FONT&gt;, despite running the script as a Python toolbox.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This will happen a couple of times, and then ArcGIS Pro will revert to its expected behaviour.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Sep 2022 12:48:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/oserror-when-using-arcpy-mp-arcgisproject/m-p/1213375#M6357</guid>
      <dc:creator>gh8reth</dc:creator>
      <dc:date>2022-09-16T12:48:38Z</dc:date>
    </item>
  </channel>
</rss>

