Select to view content in your preferred language

Cannot make feature layer in GP Service.  It works as a tool.

2667
5
06-08-2012 01:25 PM
WesleyMarcell
Occasional Contributor
I am having an odd problem and cannot find a solution.  I have a pretty lengthy script that is getting hung up near the beginning.  When the script reaches the command arcpy.MakeFeatureLayer_management(input, 'lyr') I recieve the following message:

<type 'exceptions.AttributeError'>: UNKNOWN
Failed to execute

I really have no idea what is happening.  I can write the input fc to another location using fc2fc_conversion so I know the path is good.  I have checked and the output featureLayer name is not in memory.  It is like when the script is ran through a GP Service it does not have permission to write to the temp directory/ in memory or wherever it would store a feature layer.

I have inserted a little of the code but it is a 500 line script.  Hope someone can help.

inputs_GDB      = r"c:\hydrologic_modeling\scratch\scratch.gdb"
# Data: KY_Pilot_LiDAR_Model_INPUTS GDB Variables
    Watersheds_from_LiDAR = inputs_GDB + os.sep + r"Other_INPUTS\watersheds_fr_LiDAR"
    arcpy.AddMessage(Watersheds_from_LiDAR)
    desc = arcpy.Describe(Watersheds_from_LiDAR)
    arcpy.AddMessage(desc.dataType)
    arcpy.AddMessage(scratchWS)
    arcpy.AddMessage(arcpy.env.workspace)
    # gp.environment: Set Processing Extent
    arcpy.FeatureClassToFeatureClass_conversion(Watersheds_from_LiDAR, projectArea_GDB, "watersheds_fr_LiDAR")
    arcpy.env.extent = Watersheds_from_LiDAR

##    arcpy.AddMessage(str(arcpy.env.extent)

    # Process: Make Feature Layer
    arcpy.MakeFeatureLayer_management(Watersheds_from_LiDAR, "watershed_lyr")#, "", inputs_GDB)
    arcpy.AddMessage("made")
0 Kudos
5 Replies
NobbirAhmed
Esri Regular Contributor
Could you please let me know what messages you get when you wrap your Make Feature Layer line with try-except as follows?

try:
    arcpy.MakeFeatureLayer_management(Watersheds_from_LiDAR, "watershed_lyr")
except:
    print arcpy.GetMessages(2)
    arcpy.AddMessage(arcpy.GetMessages(2))
0 Kudos
WesleyMarcell
Occasional Contributor
I attempted the change below and in the results window it returns no message.  It has the little info message symbol but it is blank next to it.  I put a print line below to say done.  Not sure what is going on...[ATTACH=CONFIG]15109[/ATTACH]




Could you please let me know what messages you get when you wrap your Make Feature Layer line with try-except as follows?

try:
    arcpy.MakeFeatureLayer_management(Watersheds_from_LiDAR, "watershed_lyr")
except:
    print arcpy.GetMessages(2)
    arcpy.AddMessage(arcpy.GetMessages(2))
0 Kudos
NobbirAhmed
Esri Regular Contributor
Does the workflow run successfully on Desktop?

If you can share your model & data then we can try to reproduce the issue and find what's going on. Thanks.
0 Kudos
WesleyMarcell
Occasional Contributor
yes it works as a script tool through ArcMap.  It is a pretty large project ~7gb of data.  I have worked on this with ESRI support so I may open another ticket.  ESRI was very helpful getting the script migrated from 9.2 to 10.0 however I am now attempting to set this up as a GP service so there may be some permission issues between the SOC and wherever it writes the temporary Feature Layers when executing the script.  I appreciate the help though.  I was hoping for an easy fix.
0 Kudos
KaushalShah
Emerging Contributor
I am facing similar issue on 7 May 2014.
I get the error :- Runtime error <type 'exceptions.AttributeError'>: UNKNOWN
I get the above error when I try to run the GP commands like
arcpy.MakeFeatureLayer_management or arcpy.Delete_management.

The above python command works on 1 machine, but gives the above error on another machine, reasons unknown. The ArcGIS Desktop installed on both machines is 10.0 SP5 Build 4400.

Please suggest urgently as it's blocking the deliveries.

Regards,
Kaushal Shah.
0 Kudos