Script stopped working properly with upgrade of ArcGIS Pro

05-06-2021 06:54 AM
Occasional Contributor

I created a Python script that calculates fields of newly added points. When I run the script in ArcGIS Pro 2.5 everything works correctly, but when I upgraded to version 2.7.3 of Pro, 3 of the fields no longer populate. I don't get any errors from the script. Thanks in advance for any help!

import arcpy

#Setup the user inputs
customerPointSelection = arcpy.GetParameterAsText(0)
customerPoint = arcpy.GetParameterAsText(1)
automatedCollection = arcpy.GetParameterAsText(2)

#Create a spatial join between customerPointSelection and automatedCollection
arcpy.SpatialJoin_analysis(customerPointSelection, automatedCollection, "in_memory/CustomerAutoJoin", "JOIN_ONE_TO_MANY","KEEP_COMMON","","WITHIN")
#Create a new join to the customerPoint
#Calculate the needed fields
#Remove the join and delete the in memory feature


0 Kudos
5 Replies
New Contributor II
try management.CalculateField for all field calculations
not CalculateField_management
0 Kudos
MVP Esteemed Contributor


Calculate Field (Data Management)—ArcGIS Pro | Documentation

You can examine the code and its location and you will see that both methods lead to the exact same function in the same file.  The "dot notation" is now preferred but the other is still usable.


from arcpy import CalculateField_management

from import CalculateField

# ---- use help on either one

@gptooldoc('CalculateField_management', None)
def CalculateField(in_table=None, field=None, expression=None, expression_type=None, code_block=None, field_type=None, enforce_domains=None):
.... snip ....
File:      c:\arc_pro\resources\arcpy\arcpy\
Type:      function



... sort of retired...
New Contributor II
This example works for me using the latest base arcgis pro python that's all I got!  Good luck.
fieldName = r'SYS_TRANSFER_DATE'
expression = f"'{current_utc}' if !SYS_TRANSFER_DATE! is None else !SYS_TRANSFER_DATE!"
arcpy.CalculateField_management(workspace, fieldName, expression, "PYTHON3")
0 Kudos
Occasional Contributor

Thank you @r3weber and @DanPatterson for suggesting using the dot notation. I changed the script to include the dot notation and was getting the same results. I looked at the results from the spatial join layer and the spatial join layer isn't getting all the attributes from the polygon layer, but I'm not exactly sure why some of the fields aren't getting populated even though the polygon layer has attributes for those fields.

0 Kudos
by Anonymous User
Not applicable

I've had mixed results between using 'in_memory' and 'memory' with python 3 scripts.  Some work with using  'memory' and others work with using 'in_memory'. If you haven't already, try just 'memory' or writing to disk to see the results at each step.

I've also had mixed results with using dot notation while using pycharm. Ran as a script tool, it works but when I run it externally as a standalone script it throws errors.