I have built a Script Tool (from a modelbuilder model) in ArcGIS 10.2 which works perfectly fine in ArcGIS.
However, I am getting the following error message when I try to publish this script tool into a geoprocessing service on ArcGIS Server.
I am using in_memory workspace for outputs. Not sure if that is causing the problem.
Error Message -
> # 5 & 6 - District Query & Final Query
> if District == "Citywide":
> gp.AddMessage (("Selected Citywide Stolen Autos..." ))
> Final_Query = Query + Select_the_Date_Range + " AND " + SQL_Query_Refining_the_Data
>
> else:
> Select_the_District = "(DC_DISTRICT = " + District + ")"
> Final_Query = Query + Select_the_Date_Range + " AND " + Select_the_District + " AND " + SQL_Query_Refining_the_Data
>
> arcpy.env.workspace = r"in_memory"
> gp.AddMessage("")
> gp.AddMessage("---------------------------------------------------------------------------------------------")
> gp.AddMessage (("Querying the PIIN table for dates from " + Date_FROM + " to " + Date_TO + " & District = " + District ))
>
> # Process 1 : Querying the PIIN Table and exporting the selection to a in memory FC
> arcpy.MakeQueryLayer_management(InputDatabase, "StolenRec_ActiveStol_FC", Final_Query)
> arcpy.CopyFeatures_management("StolenRec_ActiveStol_FC", StolenRec_ActiveStol_FC_3)
>
>
> gp.AddMessage (("Making XY Event Layer from Recovered Location..." ))
> # Process 2: Making XY Event Layer
> arcpy.TableToTable_conversion("StolenRec_ActiveStol_FC", "in_memory" , "StolenRec_ActiveStol_FC_2", "")
> arcpy.MakeXYEventLayer_management("StolenRec_ActiveStol_FC_2", "RECOVERED_X_COORD", "RECOVERED_Y_COORD", "Recovered_ELayer",
> "PROJCS['NAD_1983_StatePlane_Pennsylvania_South_FIPS_3702_Feet',GEOGCS['GCS_North_American_1983',DATUM['D_North_American_1983',SPHEROID['GRS_1980',6378137.0,298.257222101]],PRIMEM['Greenwich',0.0],UNIT['Degree',0.0174532925199433]],PROJECTION['Lambert_Conformal_Conic'],PARAMETER['False_Easting',1968500.0],PARAMETER['False_Northing',0.0],PARAMETER['Central_Meridian',-77.75],PARAMETER['Standard_Parallel_1',39.93333333333333],PARAMETER['Standard_Parallel_2',40.96666666666667],PARAMETER['Latitude_Of_Origin',39.33333333333334],UNIT['Foot_US',0.3048006096012192]];-119214200
> -96198500 3048.00609601219;-100000 10000;-100000 10000;3.28083333333333E-03;0.001;0.001;IsHighPrecision", "")
>
> gp.AddMessage (("Converting XY Event Layer to FC..." ))
> # Process 3: Converting XY Event Layer to a in memory Point Feature Class
> #arcpy.FeatureClassToFeatureClass_conversion(Recovered_ELayer, in_memory, "Recovered_FC_Layer","")
> arcpy.CopyFeatures_management("Recovered_ELayer", Recovered_FC_Layer_2)
arcpy.Exists()
and print statements.("in_memory/StolenRec_ActiveStol_FC_3")
, don't rely on the arcpy.env.workspace to build the path on your behalf.