<?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: ArcGIS Pro Toolbox &amp;amp; __pycache__ in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-toolbox-amp-pycache/m-p/1364606#M76770</link>
    <description>&lt;P&gt;So odd!&amp;nbsp; This is not a step I ever had to do under ArcGIS Desktop/Python 2, and I was just as regularly tinkering with under-development tools under the hood like this.&lt;/P&gt;&lt;P&gt;Guess I'll have to go dive into the world of importlib, now.&lt;/P&gt;</description>
    <pubDate>Wed, 27 Dec 2023 21:22:33 GMT</pubDate>
    <dc:creator>MErikReedAugusta</dc:creator>
    <dc:date>2023-12-27T21:22:33Z</dc:date>
    <item>
      <title>ArcGIS Pro Toolbox &amp; __pycache__</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-toolbox-amp-pycache/m-p/1364537#M76760</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Disclaimer:&lt;/STRONG&gt; There seem to be differences here both between ArcMap and ArcPro, as well as Python 2 and Python 3.&amp;nbsp; That said, the issue&amp;nbsp;&lt;EM&gt;seems&lt;/EM&gt; to be on ArcPro's end.&lt;/P&gt;&lt;P&gt;--------------------------------------------------&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Simplified Precis:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;I have a geoprocessing tool that runs on a script we'll call&amp;nbsp;&lt;STRONG&gt;Toolscript.py&lt;/STRONG&gt;.&amp;nbsp; This is part of a suite of tools I build &amp;amp; maintain for our team, and they reference a core library that we'll call&amp;nbsp;&lt;STRONG&gt;Assets.py&lt;/STRONG&gt;.&amp;nbsp; Toolscript.py imports Assets.py, and python automatically creates &lt;STRONG&gt;Assets.pyc&lt;/STRONG&gt; at runtime.&amp;nbsp; In the old Desktop days with Python 2, this would be saved in the same place as the&amp;nbsp;&lt;STRONG&gt;Assets.py&lt;/STRONG&gt;, whereas Python 3 now puts the compiled file in a __pycache__ subdirectory.&lt;/P&gt;&lt;P&gt;If I make edits to&amp;nbsp;&lt;STRONG&gt;Assets.py&lt;/STRONG&gt;, I generally delete &lt;STRONG&gt;Assets.pyc&lt;/STRONG&gt;, and have Python generate a fresh one.&amp;nbsp; Especially if I'm actively writing &amp;amp; testing a script, I will end up doing this frequently, to make sure that my tool that I'm testing is actually using the correct version of the library file.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The Problem:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;In ArcGIS Desktop 10.7, deleting &lt;STRONG&gt;Assets.pyc&lt;/STRONG&gt;&amp;nbsp;was all I had to do, and I could easily test &amp;amp; iterate on the fly.&amp;nbsp; My tools always imported the most current version of the library, without restarting ArcGIS.&lt;/P&gt;&lt;P&gt;In ArcGIS Pro 3.1, there seems to be a cached file stored&amp;nbsp;&lt;EM&gt;inside ArcGIS Pro&lt;/EM&gt;.&amp;nbsp; Even when I delete&amp;nbsp;&lt;STRONG&gt;Assets.pyc&lt;/STRONG&gt;, my tools seem to try to reference the old file.&amp;nbsp; In addition to not getting expected results from whatever fix I just coded, my tracebacks start pointing to nonsense like blank lines (assumedly because the &lt;STRONG&gt;Assets.py&lt;/STRONG&gt; and&amp;nbsp;&lt;STRONG&gt;Assets.pyc&lt;/STRONG&gt; being referenced by ArcGIS Pro no longer match.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This means any time I make even a minor change to&amp;nbsp;&lt;STRONG&gt;Assets.py&lt;/STRONG&gt;, I have to&amp;nbsp;delete &lt;STRONG&gt;Assets.pyc&lt;/STRONG&gt; &lt;U&gt;&lt;EM&gt;&lt;STRONG&gt;AND&lt;/STRONG&gt;&lt;/EM&gt;&lt;/U&gt;&amp;nbsp;close ArcGIS Pro.&amp;nbsp; This is hugely inefficient when I'm in active R&amp;amp;D and needing to fix things in&amp;nbsp;&lt;STRONG&gt;Assets.py&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there a setting I've missed somewhere or some misunderstanding of how ArcGIS Pro handles imported python scripts, now?&amp;nbsp; I've dug up a few old posts on similar issues, but they mostly seem to have been muddied with other issues and/or not actually solved.&amp;nbsp; I've also seen reference to importing the&amp;nbsp;&lt;STRONG&gt;reload&lt;/STRONG&gt; module from&amp;nbsp;&lt;STRONG&gt;importlib&lt;/STRONG&gt;, but I can't help but wonder why I suddenly need this in Pro when I didn't back in Desktop?&amp;nbsp; I'm not seeing this come up outside of ArcGIS in other Python discussions, though admittedly that searching has been limited.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 17:31:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-toolbox-amp-pycache/m-p/1364537#M76760</guid>
      <dc:creator>MErikReedAugusta</dc:creator>
      <dc:date>2023-12-27T17:31:17Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Toolbox &amp; __pycache__</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-toolbox-amp-pycache/m-p/1364558#M76763</link>
      <description>&lt;P&gt;related&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1223626" target="_blank"&gt;Solved: Need to restart Pro every time I edit a toolbox's ... - Esri Community&lt;/A&gt;&lt;/P&gt;&lt;P&gt;and yes importlib 's reload is the way to go if you import other modules when editing.&lt;/P&gt;&lt;P&gt;It has been too long since using ArcMap's python to know if it was a python 2 vs 3 issue.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 18:15:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-toolbox-amp-pycache/m-p/1364558#M76763</guid>
      <dc:creator>DanPatterson</dc:creator>
      <dc:date>2023-12-27T18:15:32Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Toolbox &amp; __pycache__</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-toolbox-amp-pycache/m-p/1364606#M76770</link>
      <description>&lt;P&gt;So odd!&amp;nbsp; This is not a step I ever had to do under ArcGIS Desktop/Python 2, and I was just as regularly tinkering with under-development tools under the hood like this.&lt;/P&gt;&lt;P&gt;Guess I'll have to go dive into the world of importlib, now.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Dec 2023 21:22:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-toolbox-amp-pycache/m-p/1364606#M76770</guid>
      <dc:creator>MErikReedAugusta</dc:creator>
      <dc:date>2023-12-27T21:22:33Z</dc:date>
    </item>
    <item>
      <title>Re: ArcGIS Pro Toolbox &amp; __pycache__</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-toolbox-amp-pycache/m-p/1383472#M78988</link>
      <description>&lt;P&gt;I haven't closely checked, but I think this is due to changes in the caching system of Python 2 vs 3. Deleting the .pyc was a handy trick, but perhaps not a directly supported "feature" from the Python developers perspective, sometimes cached module loading introduces other downstream issues, and typically Python executions expect to only import something once.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;There are tools like IPython's auto reload module which allows hot reloading (&lt;A href="https://ipython.readthedocs.io/en/stable/config/extensions/autoreload.html" target="_blank"&gt;https://ipython.readthedocs.io/en/stable/config/extensions/autoreload.html&lt;/A&gt;) but using importlib is the best general practice currently because it is explicit. We've discussed having some kind of 'debug' mode that would try to reimport modules, but nothing in the software today for that.&lt;BR /&gt;&lt;BR /&gt;Cheers, Shaun&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Feb 2024 16:31:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/arcgis-pro-toolbox-amp-pycache/m-p/1383472#M78988</guid>
      <dc:creator>ShaunWalbridge</dc:creator>
      <dc:date>2024-02-16T16:31:40Z</dc:date>
    </item>
  </channel>
</rss>

