Syntax Error When Attempting to Add Custom Toolbox to Python Script

871
4
05-14-2012 05:29 AM
JeffAdams
New Contributor
I am trying to add a custom toolbox to a python script. Seems like a pretty simple coding exercise, but I am getting an incorrect syntax error.

The code I am using is as follows:

#Import modules
import sys, os, arcpy, string

arcpy.ImportToolbox("C:/Data/Custom Tools.tbx", "custom")

Any thoughts? I am running ArcGIS Desktop 10 (service pack 4) with licensing for ArcMap and Spatial Analyst. Do you need full ArcGIS
licensing to add a a toolbox to a python script? Thanks...

Jeff
Tags (2)
0 Kudos
4 Replies
DanPatterson_Retired
MVP Emeritus
It might be the space in the toolbox name.
0 Kudos
MathewCoyle
Frequent Contributor
Are you getting an error on your toolbox import or when you try to execute tools from the toolbox?
0 Kudos
JeffAdams
New Contributor
It might be the space in the toolbox name.


Thanks for the response. I had tried renaming the toolbox without spaces, no luck...
0 Kudos
JeffAdams
New Contributor
Are you getting an error on your toolbox import or when you try to execute tools from the toolbox?


I have this code (single task of trying to load a toolbox) attached to a script that I run from a toolbox. The error appears a few seconds or so after I hit the run button of the script tool. The tool appears to be giving it a go, but then produces the invalid syntax error. I have tried loading a custom toolbox (as in my example) and an ArcGIS toolbox, no luck.
0 Kudos