2

I have a script that imports a custom toolbox, copies data from an sde to a file/personal gdb, removes custom feature class extensions, etc. The script runs fine in Catalog, but I receive the following error in PyScripter:

Traceback (most recent call last):
  File "C:\Clients\Custom.py", line 45, in <module>
    arcpy.UpdateMDB(gisIn, wsOut)
AttributeError: 'module' object has no attribute 'UpdateMDB'

UpdateMDB is a toolbox tool and the portion of the problem script that copies data to a file or personal gdb. The tool runs great in Toolbox. On a co-worker's machine, arcpy.UpdateMDB runs correctly in the same script, but throws an error on mine. I've also seen references for arcpy.Update_tools and arcpy.UpdateMDB_Company_Tools in help documents, but these also throw an error.

In the problematic script, I'm importing my custom toolbox like this:

tbx = r'C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Company Tools.tbx'

I'm running ArcGIS 10.2.2 on a 32-bit computer. We do a lot of testing in PyScripter, so I'm trying to figure this one out. It seems like it could be an easy fix - any ideas?

3
  • Sounds like a Python Path issue. Both ArcMap and Catalog use python in some like "C:\Python27\ArcGIS10.3" pyScripter may be set to use a different interpreter. Mar 8, 2016 at 16:47
  • At the top of the script, I sometimes add the script folder to PythonPath. thisdir = os.path.dirname(os.path.realpath(file)) sys.path.append(thisdir)
    – klewis
    Mar 8, 2016 at 19:19
  • Have you tried passing tbx to the arcpy.ImportToolbox function?
    – Nxaunxau
    Mar 8, 2016 at 23:22

2 Answers 2

1

Try this tbx = arcpy.ImportToolbox (path_to_tbx)

0

Thanks for the responses. The problem seemed to be that the custom toolbox was located in two locations and was causing a conflict. The toolbox was located in the default location: C:\Program Files\ArcGIS\ArcToolbox\Toolboxes\Company Tools.tbx and also here: C:\Program Files\ArcGIS\Desktop10.2\ArcToolbox\Toolboxes\Company Tools.tbx

Before deleting the duplicate, I tried renaming the tbx and then changing the alias, but this did not work.

Once the tbx under Desktop10.2 was deleted, the scripts ran correctly. Having duplicate toolboxes was not a problem when running the tools from ArcCatalog and ArcMap python windows, only when testing in PyScripter.

Your Answer

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

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