Using ArcGIS 10.2.1 and Python 2.7
My python addin works in ArcMap if I open ArcMap with the Python window open, but if I open ArcMap without the Python window open - I get a "MISSING" tool error. enter image description here See code below.
import arcpy
import pythonaddins
class IntersectionSearchCmb(object):
"""Implementation for IntersectionSearch_addin.combobox (ComboBox)"""
def __init__(self):
arcpy.AddMessage("HERE I AM 1")
print "Here i am 1"
cur,row = None, None
self.street_list = []
self.street_dict = {}
self.street_list.append("Battle St at 6th Ave")
self.street_list.append("6th Ave at Battle St")
self.street_dict["Battle St at 6th Ave"] = [688855.366,5616889]
self.street_dict["6th Ave at Battle St"] = [688855.366,5616889]
self.street_list.sort()
#self.street = list(set(self.street))
self.items = self.street_list
self.editable = True
self.enabled = True
self.width = 'WWWWWWWWWWW'
self.dropdownWidth = 'WWWWWWWWWWWWWWWWWWWWWWWWWW'
def onSelChange(self, selection):
arcpy.AddMessage("HERE I AM 2")
print "Here i am 2"
self.mxd = arcpy.mapping.MapDocument('current')
self.df = arcpy.mapping.ListDataFrames(self.mxd)[0]
try:
x = self.street_dict[selection][0]
y = self.street_dict[selection][1]
extent = arcpy.Extent(x,y,x,y)
self.df.panToExtent(extent)
self.df.scale = 1500
arcpy.RefreshActiveView()
except:
pass
def onEditChange(self, text):
pass
def onFocus(self, focused):
arcpy.AddMessage("HERE I AM 3")
print "Here i am 3"
self.mxd = arcpy.mapping.MapDocument('current')
self.df = arcpy.mapping.ListDataFrames(self.mxd)[0]
pass
def onEnter(self):
pass
def refresh(self):
pass
-
Please add the text of the error message you are receiving.Bjorn– Bjorn2017年06月21日 20:46:33 +00:00Commented Jun 21, 2017 at 20:46
-
I am not recieving an error message - just the tool within ArcMap is shown as [Missing]. No errors. I have attached the screen shot of the error in the original question now.dklassen– dklassen2017年06月21日 20:48:53 +00:00Commented Jun 21, 2017 at 20:48
-
1I think your config.xml and ArcPy code may be out of sync.PolyGeo– PolyGeo ♦2017年06月21日 20:51:39 +00:00Commented Jun 21, 2017 at 20:51
-
Any ideas on how to test this? I have re-compiled it, but perhaps I need to re-create it from scratch?dklassen– dklassen2017年06月21日 20:57:11 +00:00Commented Jun 21, 2017 at 20:57
-
1Does it work on another machine? I have seen this before - addin icons showed on several computers and didn't show on several others.Midavalo– Midavalo ♦2017年06月21日 21:09:19 +00:00Commented Jun 21, 2017 at 21:09
1 Answer 1
Found the answer to my own question: the file C:\Python27\ArcGIS10.2\Lib\site-packages\desktop10.2.pth wasn't structured correctly. It was missing these 3 lines:
c:\Program Files (x86)\ArcGIS\Desktop10.2\bin
c:\Program Files (x86)\ArcGIS\Desktop10.2\arcpy
c:\Program Files (x86)\ArcGIS\Desktop10.2\ArcToolbox\Scripts
Once these lines were added to the desktop10.2.pth file - everything worked correctly. I think our Python was installed incorrectly. Thanks for all your suggestions!