I am attempting to delete a list of fields in a feature layer but am getting an error:

Execute error: Failed to execute. Parameters are not valid. ERROR 000308 Invalid Field type

Here is a code snippet:

arcpy.MakeFeatureLayer_management(roads, tmprds)

arcpy.DeleteField_management(tmprds, ["FIELD_NAME"])

I have listed the fields in my feature layer using:

fclass = tmprds
fieldnames = [f.name for f in arcpy.ListFields(fclass)]
print (fieldnames)

and I get a list of layers formatted like:

[u'FIELD1', u'FIELD2, u'FIELD3']

I have tried using both IN_MEMORY and real locations which don't seem to make a difference.

Where am I going wrong?


  • Couple of obvious questions that need answering, Your ListFields call returns field1, field2 and field3 but in your deleteField you supply a list of 1 field called "FIELD_NAME", this is clearly a field that does not exist in your dataset! Also what is tmprds set to as this make be invalid? – Hornbydd May 29 '14 at 16:38
  • Sorry for the confusion - the names that I supplied were just generic field names so as to avoid printing unnecessary details. The list of layers returns e.g. u'FIELD1' and I attempt to delete that field using "FIELD1". I have tried both: tmprds = r'C:\mydb.gdb\temprds' and tmprds = "IN_MEMORY\\tmprds" – user30531 May 29 '14 at 16:54
  • I don't think you can supply the field name as a list, I think you would have to create a loop to iterate through the list like for field in fieldnames fN = field..... arcpy.DeleteField_management(tmprds, fN ) – landocalrissian May 29 '14 at 17:23
  • The esri help example uses a list and I have had a list work before in a previous script. – user30531 May 29 '14 at 17:28
  • I see, I did notice two things esri's list didn't have the Unicode [u'FIELD1'] but rather just the string name ["FIELD1"] also they input the list variable not in brackets like this arcpy.DeleteField_management(tmprds, fieldnames) – landocalrissian May 29 '14 at 17:40

Here is how I would go about troubleshooting this one:

  1. Build the same logic using ModelBuilder
  2. Run the script to confirm it work error free
  3. Export to Python
  4. Look at the script for the exact syntax

Also please note that you don't need to create a feature layer to delete a field - you can perform this task directly on the feature class.

  • 1
    Welcome to GIS SE! +1 for sound advice but I think most of us prefer to use Copy As Python Snippet in the Geoprocessing | Results window rather than ModelBuilder to do the manual stepthrough nowadays. The code generated that way is much easier to read/debug than what comes out of ModelBuilder. – PolyGeo May 30 '14 at 2:00
  • Thanks for the warm welcome @PolyGeo7. You have a valid point. I guess you can call me old school :) – ericchiasson May 30 '14 at 9:22
  • Thanks. I created a feature layer so as to not make my edits on the original FC. I find the code from model builder to be unnecessarily messy, I prefer to code directly in an IDE although I can see the value in finding possible syntax errors. @PolyGeo I hadn't considered that as an option but will try it out for sure. Many thanks! – user30531 May 30 '14 at 15:44

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.