Issues importing a custom toolbox within another custom tool

3520
8
11-26-2015 10:55 AM
JamilHarvich
New Contributor II

I'm trying to call on a custom python script within another script. The tool I'm creating takes 2 feature classes as inputs. I am calling on another custom tool that was downloaded in this script. If I run my script outside of ArcGIS, using predefined paths for the two feature classes, everything works fine. When I try to run my script as a tool using "arcpy.GetParameterAsText()" I get an error saying that the other script that I am referencing can't be found.

Here is the error I get:

Traceback (most recent call last):

  File "C:\Users\jamil.harvich\Documents\ArcGIS\Python_Scripts\Working\IP_Anno\Script\Script_Part1.py", line 80, in <module>

    arcpy.ConcatenateRowValues_IP(lyr[0] + '_Intersect', 'SHORT_DESC', 'NAME', lyr[2], '-')

  File "C:\Users\jamil.harvich\Documents\ArcGIS\Python_Scripts\Working\IP_Anno\IP_Labels.tbx", line 54, in ConcatenateRowValues

    qN9X/X6ErfAD4ZAf8k08Gf8AhO2X/wAapjfAH4aY4+Gngz/wnLL/AONVgXPxuMvibxL4gsZzfeA/

AttributeError: Object: Tool or environment <ConcatenateRowValues_IP> not found

Tags (2)
0 Kudos
8 Replies
DanPatterson_Retired
MVP Emeritus

are you providing the full path to the toolbox?

0 Kudos
JamilHarvich
New Contributor II

Yes I am. The script runs fine outside of ArcGIS, but as soon as I try to make it a tool with parameters, it gives me the error.

0 Kudos
DanPatterson_Retired
MVP Emeritus

so I presume you have an addtoolbox somewhere in your script? AddToolbox—Help | ArcGIS for Desktop

JamilHarvich
New Contributor II

Yeah I do. Its the first line I have in the code after import arcpy.

arcpy.ImportToolbox(r'C:\Users\jamil.harvich\Documents\ArcGIS\Python_Scripts\Working\IP_Anno\IP_Labels.tbx', 'IP')

Can you see any problems with the syntax here?

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

I'm assuming the 'IP' is the module name?   looks like that is optional...can you try it without the second argument?

JamilHarvich
New Contributor II

I've tried it without as well. Sorry that example was just my last attempt at it. As far as I can tell, the second argument is required only if the toolbox doesn't have an alias defined. But this one does. I was just experimenting.

0 Kudos
DanPatterson_Retired
MVP Emeritus

put your toolbox in a simpler location, one with a period,or space for example and see if it loads from there

JamilHarvich
New Contributor II

Still no luck. I found a workaround by copying and pasting the code from the other tool directly into my script as a function. I included credits in the code, so hopefully it doesn't count as plagiarizing. Thanks for the help anyway.