laptop and a wrench

Error

The Calculate Field tool results in a NameError exception when using Python variables.

Última publicación: October 28, 2015 ArcGIS for Desktop
Número de ID del error BUG-000091442
EnviadoOctober 15, 2015
Última modificaciónJune 5, 2024
Relacionado conArcGIS for Desktop
Versión encontrada10.2.2
Sistema operativoWindows OS
Versión de sistema operativo7.0 64 Bit
EstadoKnown Limit

Información adicional

Changes were made around 10.2.2 to properly isolate script tool code, validation and tool like Calculate Field and Calculate Value that use Python internally. Prior to this change, there was potential for confusing and unexpected issues that would be hard to isolate because a variable could be changed in one tool that would impact another tool. The best strategy for passing variables into CalculateField is using string formatting as shown in the workaround.

Solución alternativa

Use the following code:arcpy.CalculateField_management(table,"gayu", "({0} + 1) / 2".format(funcg), "PYTHON", "")

Pasos para reproducir

ID del error: BUG-000091442

Software:

  • ArcGIS for Desktop

Recibir notificaciones cuando cambie el estado de un error

Descargar la aplicación de soporte de Esri

Descubrir más sobre este tema

Obtener ayuda de expertos en ArcGIS

Contactar con el soporte técnico

Descargar la aplicación de soporte de Esri

Ir a opciones de descarga