I have been developing a few python addins and I'm just wondering what is the best way to re-compile the addin anytime I edit the script.

Currently, if I make an edit to the script, it seems like I have to

  1. Close ArcMap
  2. Go to My addin folder and double click the 'makeaddin' python file
  3. Double click the 'Python Addin File
  4. Restart ArcMap for the changes to come into effect

If I don't do these steps, then the edits aren't recognized. This gets pretty annoying and time consuming when I want to place maybe a simple print line somewhere or I do a small edit just to test a result.

Is there a better way of doing this?

4 Answers 4


You can use the builtin reload function in python to automatically reload your module. What you can do is something like this:

import mymodule

def hook():

where hook() is what's called by ArcMap and mymodule is the module you're editing between invocations. You may have to edit sys.path to include the path of the module you're editing so that import mymodule does not fail. Or include the directory in site-packages (maybe using python setup.py develop).

  • 1
    Of course this would only be helpful during development; I believe the ArcGIS designers intend for you to test your script before building the addin (resources.arcgis.com/en/help/main/10.1/index.html#/…)
    – cwa
    Commented Feb 20, 2013 at 23:47
  • This is what I do as well. I also use winpdb for embedded debugging.
    – blah238
    Commented Feb 21, 2013 at 0:42
  • Thanks for the suggestion. This is a little beyond my skill set. Is it difficult to implement? Is there any further information about this that I can use to learn?
    – Mike
    Commented Feb 21, 2013 at 16:19
  • 1
    I'm a python developer with limited ArcGIS experience, but I'm learning it. I'll update with more details after I figure them out.
    – cwa
    Commented Feb 21, 2013 at 18:49
  • @blah238 how did you configure the embedded debugging? My addin will connect but drops the connection after it's loaded. Commented Nov 11, 2013 at 23:00

Per @blah238's suggestion, the following script

  1. closes ArcMap (if open)
  2. creates Add-in
  3. installs Add-in silently
  4. re-opens ArcMap document

Save to directory containing makeaddin.py:

import os

#Location of ESRIRegAddIn.exe
esri = "C:/Program Files (x86)/Common Files/ArcGIS/bin/ESRIRegAddIn.exe"
cwd = os.getcwd()
mapdoc = <path to mxd>

#Close ArcMap if it is open
try:    os.system("TASKKILL /F /IM ArcMap.exe")
except:    pass

#Create ESRI Add-in file
os.system(os.path.join(cwd, "makeaddin.py"))

#Silently install Add-in file. The name of the file is based on folder it's located in.
os.system('"{0}" {1} /s'.format(esri, os.path.split(cwd)[-1] + ".esriaddin"))

#Open test map document.
  • is this included in your PythonTool_addin.py file? Commented Sep 17, 2013 at 1:45
  • @ShaunLangley, no this is a separate .py file residing in the directory of makeaddin.py
    – Paul
    Commented Sep 17, 2013 at 3:22
  • Great script. However, as expected, ArcMap falls over when the script tries to open the .mxd file outside of ArcMap. Is there a known fix to this?
    – TheLastGIS
    Commented Jan 28, 2015 at 23:17
  • 1
    @TheLastGIS Yes. Add the variables arcmap = "C:/Program Files (x86)/ArcGIS/Desktop10.3/bin/ArcMap.exe" and Map = '"{0}" {1} /s'.format(arcmap, mapdoc) to the above. Then os.system(Map) will succeed where os.system(mapdoc) does not. Commented Apr 14, 2015 at 22:24

I received an answer on the ArcGIS website. Apparently this is the only way to re-compile python addins. Someone has logged an idea on ArcGIS Ideas and I've voted up and commented as well.

ArcGIS Discussion Forum thread is located here.

  • 1
    Could you add the relevant links to your answer?
    – blah238
    Commented Feb 22, 2013 at 20:15
  • I wanted to vote for but could not find the ArcGIS Idea that @Mike mentions.
    – PolyGeo
    Commented May 28, 2013 at 22:22
  • Sorry, I didn't see this reply until now. Thanks @PolyGeo for updating the link to the ArcGIS website.
    – Mike
    Commented Jun 4, 2013 at 16:27

I generally use two approaches: one is, for any tools you use that are really just geoprocessing, allow them to be imported, and then you can set up an interactive Python session, and do reload(mymodule) as mentioned to include the newest changes (or set up autoreload in IPython). If you are just making changes to a Python toolbox, you can reload the toolbox by right clicking on it in Catalog view and clicking 'Refresh'.

For code that does require user interaction in the GUI, I use the following batch script to speed up the process:

@echo off
echo building...
python makeaddin.py
echo installing...
start myaddin.esriaddin
echo load ArcMap...
start %HOMEDRIVE%%HOMEPATH%\Documents\ArcGIS\myaddin.mxd

Where myaddin.mxd has data layers and context that I use for the specific project. This will fire the addin install and ArcMap simultaneously, but I can usually click on the 'Install Add-in' button faster than ArcGIS starts. Alternatively, you could add pause before the last command to wait for input prior to starting ArcGIS.

  • 1
    You could use ESRIRegAddIn.exe with the /s switch to install the add-in silently. The path to ESRIRegAddIn on my machine is C:\Program Files (x86)\Common Files\ArcGIS\bin.
    – blah238
    Commented Jun 5, 2013 at 1:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.