<?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 Need to restart Pro every time I edit a toolbox's scripts in ArcGIS Pro Questions</title>
    <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1223626#M61305</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Here's my workflow:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Run toolbox in Pro. Toolbox refers to custom python scripts that I wrote.&lt;/LI&gt;&lt;LI&gt;Make tweak/edit in python script.&lt;/LI&gt;&lt;LI&gt;I *want* to be able to just re-run the tool in Pro after making the tweaks. However, in order for the script tweaks to have effect, I usually (though not always) have to restart Pro, which is annoying.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Is there a faster/more convenient way to "refresh" so that script changes are reflected when running the toolbox? I've tried clearing __pycache__ folder in the toolbox folder, but that doesn't do anything.&lt;/P&gt;&lt;P&gt;I'm using Arc Pro 3.0.2.&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;</description>
    <pubDate>Wed, 19 Oct 2022 22:35:11 GMT</pubDate>
    <dc:creator>DarrenConly</dc:creator>
    <dc:date>2022-10-19T22:35:11Z</dc:date>
    <item>
      <title>Need to restart Pro every time I edit a toolbox's scripts</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1223626#M61305</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;Here's my workflow:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Run toolbox in Pro. Toolbox refers to custom python scripts that I wrote.&lt;/LI&gt;&lt;LI&gt;Make tweak/edit in python script.&lt;/LI&gt;&lt;LI&gt;I *want* to be able to just re-run the tool in Pro after making the tweaks. However, in order for the script tweaks to have effect, I usually (though not always) have to restart Pro, which is annoying.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Is there a faster/more convenient way to "refresh" so that script changes are reflected when running the toolbox? I've tried clearing __pycache__ folder in the toolbox folder, but that doesn't do anything.&lt;/P&gt;&lt;P&gt;I'm using Arc Pro 3.0.2.&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;</description>
      <pubDate>Wed, 19 Oct 2022 22:35:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1223626#M61305</guid>
      <dc:creator>DarrenConly</dc:creator>
      <dc:date>2022-10-19T22:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Need to restart Pro every time I edit a toolbox's scripts</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1223703#M61315</link>
      <description>&lt;P&gt;For a Python toolbox (.pyt):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;in the pyt, reload the imported modules. this will recompile it into the pycache folder&lt;/LI&gt;&lt;LI&gt;refresh the toolbox in Pro. this will make it reread the pycache&lt;/LI&gt;&lt;/UL&gt;&lt;LI-CODE lang="python"&gt;# Toolbox.pyt
import arcpy
import custom_module

# reload the custom module
import importlib
importlib.reload(custom_module)

class Toolbox():
    #...&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1666248916865.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/54022i045E74EB9AEF872D/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1666248916865.png" alt="JohannesLindner_0-1666248916865.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For script tools, I'm not sure, try refreshing the toolbox in Pro.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 06:55:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1223703#M61315</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-10-20T06:55:33Z</dc:date>
    </item>
    <item>
      <title>Re: Need to restart Pro every time I edit a toolbox's scripts</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1223956#M61342</link>
      <description>&lt;P&gt;Thanks Johannes,&lt;/P&gt;&lt;P&gt;I'm using as a script tool in a toolbox (TBX). I've tried refreshing the toolbox but that doesn't seem to fix it either. Might help if in the main script called by the toolbox if I add importlib.reload() for all modules used by the script.&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2022 18:10:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1223956#M61342</guid>
      <dc:creator>DarrenConly</dc:creator>
      <dc:date>2022-10-20T18:10:29Z</dc:date>
    </item>
    <item>
      <title>Re: Need to restart Pro every time I edit a toolbox's scripts</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1242829#M63652</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/19035"&gt;@DarrenConly&lt;/a&gt;, I am unable to reproduce your issue on a later build. Are you able to upgrade to Pro 3.0.3 and reproduce there?&lt;/P&gt;&lt;P&gt;Also, please confirm that you are using .atbx with the script tool exported (vs. embedded). Like this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="HannesZiegler_0-1671573048850.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/58991iA5DF75C2370AAEEB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="HannesZiegler_0-1671573048850.png" alt="HannesZiegler_0-1671573048850.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Dec 2022 21:51:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1242829#M63652</guid>
      <dc:creator>HannesZiegler</dc:creator>
      <dc:date>2022-12-20T21:51:07Z</dc:date>
    </item>
    <item>
      <title>Re: Need to restart Pro every time I edit a toolbox's scripts</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1243013#M63673</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/50334"&gt;@HannesZiegler&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thanks for following up on this, after installing Pro 3.0.3 and confirming that script is not embedded.&lt;/P&gt;&lt;P&gt;I think I figured it out: when I edit the main script specified in the TBX, that edit will be reflected in the toolbox without needed to restart Pro. But if I edit a module script that the main script calls, I need to restart Pro.&lt;/P&gt;&lt;P&gt;Happily, however, I think I resolved even this. By using python's &lt;A href="https://docs.python.org/3/library/importlib.html#importlib.reload" target="_self"&gt;importlib.reload()&lt;/A&gt; in the main script I can force the module to reload in the main script, thus incorporating any changes I made to the module.&lt;/P&gt;&lt;P&gt;For example, instead of just putting:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import some_module as sm # module that I want to edit&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I enter:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import importlib
import some_module as sm
importlib.reload(sm) # forces reload with every run, so no need to restart Pro&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Doing the latter, I can edit the module and re-run in Pro without having to restart Pro.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 17:57:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1243013#M63673</guid>
      <dc:creator>DarrenConly</dc:creator>
      <dc:date>2022-12-21T17:57:57Z</dc:date>
    </item>
    <item>
      <title>Re: Need to restart Pro every time I edit a toolbox's scripts</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1243019#M63674</link>
      <description>&lt;P&gt;Excellent! Thank you for sharing your solution&lt;/P&gt;</description>
      <pubDate>Wed, 21 Dec 2022 18:08:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1243019#M63674</guid>
      <dc:creator>HannesZiegler</dc:creator>
      <dc:date>2022-12-21T18:08:54Z</dc:date>
    </item>
    <item>
      <title>Re: Need to restart Pro every time I edit a toolbox's scripts</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1491394#M84513</link>
      <description>&lt;P&gt;I had to reload the module, not the class. Otherwise Arc GIS would not load my .pyt file. But I could not find any errors &lt;span class="lia-unicode-emoji" title=":thinking_face:"&gt;🤔&lt;/span&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;from importlib import reload

import some_module
reload(some_module)
from some_module import sm&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jun 2024 08:45:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1491394#M84513</guid>
      <dc:creator>MortenBackNielsen</dc:creator>
      <dc:date>2024-06-13T08:45:34Z</dc:date>
    </item>
    <item>
      <title>Re: Need to restart Pro every time I edit a toolbox's scripts</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1580381#M92478</link>
      <description>&lt;P&gt;I had the same experience with pro 2.9. Thanks for the tip! This saved me a lot of headache and time since I have to run pro over RDS.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2025 14:53:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1580381#M92478</guid>
      <dc:creator>JamesTurner2</dc:creator>
      <dc:date>2025-01-30T14:53:53Z</dc:date>
    </item>
    <item>
      <title>Re: Need to restart Pro every time I edit a toolbox's scripts</title>
      <link>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1679797#M101406</link>
      <description>&lt;P&gt;The fix above didn't work for me in a complicated package structure. The following reload_module function decorator takes care of this&lt;/P&gt;&lt;LI-CODE lang="c"&gt;# -----------------------------------------------------------------------------------------
# Name:        Reload Module
# Purpose:     This package provides the reload_module decorator. When applied to the
#              the execute method of a tool, this decorator fully reloads the module
#              prior to running the tool. This enables us to pick up any code changes
#              since it was last run for ease of development.
#
# License:     GNU Affero General Public License v3.
#              Full license at &amp;lt;https://www.gnu.org/licenses/&amp;gt;
# -----------------------------------------------------------------------------------------

import sys
import os
from importlib import import_module
from functools import wraps

def reload_module(name, force=True):
    """reload_module reads in the NAME and FORCE arguments and returns the 
    actual reload_module function decorator."""
    
    def reload_module(func):
        """reload_module takes the original execute FUNC and returns a wrapper
        function with additional logic to run prior to either executing FUNC or
        reloading it."""

        @wraps(func) # provide __wrapped__ method on execute to avoid calling decorator again
        def wrapper(self, parameters, messages):
            """wrapper checks whether to load any code changes based off FORCE,
            and either calls the new execute method or the original."""

            if force:
                # delete the module we're executing and re-import it
                class_name = self.__class__.__name__
                for module in list(sys.modules):
                    if name in module:
                        del sys.modules[module]
                out = import_module(name)
                # call the updated execute method without it's decorator
                return out.__dict__[class_name].execute.__wrapped__(self, parameters, messages)
            else:
                # call the original execute method
                return func(self, parameters, messages)
        return wrapper
    return reload_module&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;It can be run be used like:&lt;/P&gt;&lt;LI-CODE lang="c"&gt;class Tool:
...
...
    @reload_module(__name__)
    def execute(self, parameters, messages):&lt;/LI-CODE&gt;</description>
      <pubDate>Sat, 24 Jan 2026 20:22:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-pro-questions/need-to-restart-pro-every-time-i-edit-a-toolbox-s/m-p/1679797#M101406</guid>
      <dc:creator>reya23</dc:creator>
      <dc:date>2026-01-24T20:22:32Z</dc:date>
    </item>
  </channel>
</rss>

