0

Fill Missing Values Tool runs perfectly fine in ArcPro, but when attempting to do the same in Python using arcpy module, it returns an error. The error message indicates a problem within the internal ArcGIS script (SSImpute.py). Can someone please provide guidance or any possible solutions to ensure that the Fill Missing Values Tool works correctly in Python?

MY SCRIPT:

import arcpy
import numpy

arcpy.env.overwriteOutput = True

# Input feature class path
fc = f"C:\\SRD\\SRD2024\\SRD2024_Final.gdb\\Temp\\PerCapitaIncomeCounties2020"

# Run fill missing values tool
arcpy.stpm.FillMissingValues(in_features = fc, fields_to_fill = "BlPCI", fill_method = "MEDIAN", conceptualization_of_spatial_relationships = "K_NEAREST_NEIGHBORS", number_of_spatial_neighbors = 4, append_to_input = "APPEND_TO_INPUT")

I tried doing the same thing (same in_feature, fields_to_fill, fill_method, conceptualization_of_spatial_relationships, number_of_spatial_neighbors, and append_to_input) in ArcPro, and it worked.

ERROR MESSAGE:

Traceback (most recent call last):
File "C:\\NRE_5585\\SRD\\SRDFinalScripts\\A2I3PerCapInc.py", line 71, in \<module\>
arcpy.stpm.FillMissingValues(in_features=fc,
File "C:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcPy\\arcpy\\stpm.py", line 1399, in FillMissingValues
raise e
File "C:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcPy\\arcpy\\stpm.py", line 1396, in FillMissingValues
retval = convertArcObjectToPythonObject(gp.FillMissingValues_stpm(\*gp_fixargs((in_features, out_features, fields_to_fill, fill_method, conceptualization_of_spatial_relationships, distance_band, temporal_neighborhood, time_field, number_of_spatial_neighbors, location_id, related_table, related_location_id, weights_matrix_file, unique_id, null_value, out_table, append_to_input), True)))
File "C:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcPy\\arcpy\\geoprocessing_base.py", line 520, in \<lambda\>
return lambda \*args: val(\*gp_fixargs(args, True))
arcgisscripting.ExecuteError: Traceback (most recent call last):
File "\<string\>", line 5010, in execute
File "C:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcToolbox\\Scripts\\SSImpute.py", line 251, in execute
values = ssi.imputeValues(fields)
File "C:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcToolbox\\Scripts\\SSImpute.py", line 1153, in imputeValues
impValuesIds, extraField, countFilledByLoc, numNeighborUsed = self.\__expandImputedValues(value, impValuesIds)
File "C:\\Program Files\\ArcGIS\\Pro\\Resources\\ArcToolbox\\Scripts\\SSImpute.py", line 1231, in \__expandImputedValues
estimatedValues = NUM.zeros_like(values, dtype = NUM.int)
File "C:\\Users\\sabin\\AppData\\Roaming\\Python\\Python39\\site-packages\\numpy_init_.py", line 305, in __getattr__
raise AttributeError(__former_attrs__\[attr\])
AttributeError: module 'numpy' has no attribute 'int'.
`np.int` was a deprecated alias for the builtin `int`. To avoid this error in existing code, use `int` by itself. Doing this will not modify any behavior and is safe. When replacing `np.int`, you may wish to use e.g. `np.int64` or `np.int32` to specify the precision. If you wish to review your current use, check the release note link for additional information.
The aliases was originally deprecated in NumPy 1.20; for more details and guidance see the original release note at:
https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations

Failed to execute (FillMissingValues).
Process finished with exit code 1\`
3
  • I think the source of your issues is your Python environment. Looks like there is an issue with the version of numpy. How do you execute your script? Does your script adds some site packages? Or do you have the PATH variable set?
    – Thomas
    Commented Mar 27, 2024 at 21:54
  • @Thomas Thank you so much for your willingness to help. I edited my post to include some more relevant lines of script. Would you be able to kindly suggest something? Commented May 3, 2024 at 4:21
  • Deprecated numpy is the issue check here - numpy.org/devdocs/release/1.20.0-notes.html#deprecations . If you are not using numpy directly in your script try upgrading other packages as well. Commented May 3, 2024 at 4:37

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.