Select to view content in your preferred language

arcpy.CalculateField_management Error

4344
19
Jump to solution
04-14-2014 08:16 AM
DanielJimenez2
Occasional Contributor
I'm using the arcpy lib in arcgis 10.1 and to work on a script. When i use the arcpy.CalculateField_management i'm getting an error . Could someone help me identify whats wrong with the expression below. I'm using VB because when i use the python calculator, python crashes at the end of the calculation so VB is the only option i have. Notice that this expression work good when using python but like i mentioned, when the python option is used. python crashes at the end of the script.

arcpy.CalculateField_management("TAZ_un_Buffer_Dissolve.shp", "totalArea","[shape.area]", "VB", "")


Traceback (most recent call last):   File "D:\CubeAlbuquerque\AlbuquerqueNewTAZ\02_Applications\02_Transit_walk_Acc ess\ptaccess_SM.py", line 55, in <module>     arcpy.CalculateField_management("TAZ_un_Buffer_Dissolve.shp", "totalArea","[ shape.area]", "VB", "")   File "C:\Program Files (x86)\ArcGIS\Desktop10.1\arcpy\arcpy\management.py", li ne 3128, in CalculateField     raise e arcgisscripting.ExecuteError: ERROR 999999: Error executing function. Failed to execute (CalculateField).
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
DanielJimenez2
Occasional Contributor
Thanks for all the help but I think I fixed the problem. The computer had two versions of python 27 installed and seems that that is the reason behind python crashing when using the CalcFiled method. I removed the version Arcgis does not use and it is not crashing anymore so its working normal now. Thanks for the help

View solution in original post

0 Kudos
19 Replies
IanMurray
Honored Contributor
I couldn't get it working with VB, but here is a valid python expression

arcpy.CalculateField_management("TAZ_un_Buffer_Dissolve.shp", "totalArea" , "!shape.area!", "PYTHON")

I tested it on an existing file I had, and it calculated the same area that already existed for that shapefile.
0 Kudos
DanielJimenez2
Occasional Contributor
I couldn't get it working with VB, but here is a valid python expression

arcpy.CalculateField_management("us_eco_l4_no_st selection", "Test" , "!shape.area!", "PYTHON")


When i use the python option, python crashes at the end of the script. I dont know why but i can only use VB  expressions
0 Kudos
JoshuaChisholm
Frequent Contributor
Hello Daniel,

I don't think you can calculate area with VB. It might be better to use Python and try to figure out why it's crashing (what error are you getting?).

I would use something like:
arcpy.CalculateField_management("TAZ_un_Buffer_Dissolve.shp","TotalArea","!Shape.area!","PYTHON","#")


Also, one quick question, the field "TotalArea" exists before you calculate field right?
0 Kudos
IanMurray
Honored Contributor
Hello Daniel,

I don't think you can calculate area with VB. It might be better to use Python and try to figure out why it's crashing (what error are you getting?).

I would use something like:
arcpy.CalculateField_management("TAZ_un_Buffer_Dissolve.shp","TotalArea","!Shape.area!","PYTHON","#")


Also, one quick question, the field "TotalArea" exists before you calculate field right?


I was thinking the same thing, I'd rather know why my code is not working then try to find a run around for it.  Also, make sure the field names match up, it is case sensitive.
0 Kudos
DanielJimenez2
Occasional Contributor
I was thinking the same thing, I'd rather know why my code is not working then try to find a run around for it.  Also, make sure the field names match up, it is case sensitive.


This is what happens when i use the python expression.[ATTACH=CONFIG]33074[/ATTACH]

The script works fine but when it finish, it gives me the error in the pic. I dont know how to debug when python crashes, i just know that when i use the VB expression, i dont get this problem.
0 Kudos
MichaelVolz
Esteemed Contributor
What is your datasource (e.g. sde feature class, file gdb feature class, personal gdb feature class, shapefile)?

What is your version of ArcGIS Desktop?

What is your operating system?
0 Kudos
DanielJimenez2
Occasional Contributor
What is your datasource (e.g. sde feature class, file gdb feature class, personal gdb feature class, shapefile)?

What is your version of ArcGIS Desktop?

What is your operating system?


The data source is just a shapefile. I'm using Arcgis 10.1(build 3035) basic license in a windows 8 machine.

I'm using this link as reference, if it is of any help

http://resources.arcgis.com/en/help/main/10.1/index.html#//00170000004m000000
0 Kudos
DanielJimenez2
Occasional Contributor
I was thinking the same thing, I'd rather know why my code is not working then try to find a run around for it.  Also, make sure the field names match up, it is case sensitive.


Yes, like i said when i used the caluclate filed python expression the script works, but it crashes when it finish working. I can open the shapefile and see all the fields and their values. Now i dont know why python crashes when i do this and i dont know how to debug something like this.
0 Kudos
JoshuaChisholm
Frequent Contributor
Hello Daniel,

Very tricky indeed. I couldn't see much from your screenshot (the resolution was too low), but I see how that is a hard problem to solve. If you comment out the arcpy.CalculateField_management line, does it run successfully without crashing at the end?
0 Kudos