jdrvar

Python script runs in PythonWin, but not in a Toolbox

Discussion created by jdrvar on Jul 15, 2013
Latest reply on Jul 29, 2014 by MBuehler-esristaff
I am new to python scripting.  I began by creating a script to clip feature classes.  The script works in PythonWin, but fails when added to a toolbox.  The script is as follows:

#Import system modules
import arcpy
from arcpy import env

#Workspace
env.workspace = "E:\User\MillageCode"

#Variables
in_features = "Sales_2006.shp"
clip_features = "EagleHarborSales_temp.shp"
out_feature_class = "Output_temp5.shp"

#Clip the Sales_2006 shapefile to the EagleHarborSales_temp shapefile
arcpy.Clip_analysis(in_features, clip_features, out_feature_class)

#Info
print arcpy.GetMessages()

I then created a toolbox and added the script to the toolbox.  I went through the script properties, created a name, label, checked store relative path names, left always run in the foreground checked, browsed to the script, left run python script in process checked, entered the input, output, and added the optional parameters. Then, I attempted to run the script in toolbox.  I specified the input feature and noticed the default output was my C Drive.  This maybe part or the entire issue.  But, Why would the output be defaulting to the C Drive, when my workspace is on my E Drive?  And how would I fix that problem?  Thanks.

Outcomes