Reloading a python toolbox during developement

2736
1
06-13-2016 01:14 PM
PatricePineault1
New Contributor III

Hello,

I started developing a python toolbox for ArcMap 10.4. From the toolbox, I import modules, which are the tools. The idea is to have one file for each Tool.

The problem is that even if I click "refresh" on the toolbox, it doesn't reload the tools inside. I have to close ArcMap and re-open it. That is not very convenient...

Is there a way to solve it?

0 Kudos
1 Reply
DanPatterson_Retired
MVP Esteemed Contributor

since you are using python 2.7 presumably, you need to include 'reload' to ensure that they are reloaded during development

add the line

import blah #your import tools/modules line

reload(blah)  # reload them during the development stage and you can comment it out later

2. Built-in Functions — Python 2.7.12rc1 documentation

In any event, once a module is imported, then it won't automatically reload once it is loaded unlessed forced.

There are fancier ways, but this is easiest to remember.  Things change in python 3.4.x

26.6. 2to3 - Automated Python 2 to 3 code translation — Python 3.4.5rc1 documentation

fixes   Converts reload() to imp.reload().