0

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 -

enter image description here Code Sample -

> # 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)
  • Do the tables, layers, and feature classes exist/what are their names? Insert a few arcpy.Exists() and print statements. – Paul Nov 23 '15 at 17:07
  • 1
    Try changing your arcpy.TableToTable_conversion to arcpy.CopyRows(). Not sure I see the real need for T2T or CRs, but the error states it cant find StolenRec_ActiveStol_FC_2 which comes from T2T and going into MakeXY. – KHibma Nov 23 '15 at 18:09
  • 1
    Also, if that doesn't solve it (I see StolenRec_ActiveStol_FC in that list as well), be explicit, not implicit. That is use full in_memory paths to items ("in_memory/StolenRec_ActiveStol_FC_3"), don't rely on the arcpy.env.workspace to build the path on your behalf. – KHibma Nov 23 '15 at 18:17
  • @Paul &@KHibma Thanks for responding. The CopyRows() & being explicit seem to did the trick. – Raj Nov 25 '15 at 16:19
1

I had this exact problem last week and it was fixed by changing

import module

to

from module import name

See Publishing Geoprocessing Service with importing of numpy in ArcGIS Server? and GeoNet for more details.

Just another one of those interesting quirks of publishing to server :-/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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