In some instances, when running Spatial Statistics tools such as the Hot Spot Analysis (Getis-Ord Gi*) and Cluster and Outlier Analysis (Anselin Local Moran's I) tools in Python, the following error message is received:
ImportError: no module named WeightsUtilities
Below are some of the possible causes for the issue:
- The path, C:\Program Files (x86)\ArcGIS\Desktop10.x\ArcToolbox\Scripts is not appended to the system PYTHONPATH variable.
- ArcGIS Desktop and the Python instance are not installed on the same drive.
This issue can also occur due to incomplete installation of ArcGIS for Desktop. To fix this, perform a clean uninstallation and reinstallation of ArcGIS for Desktop. Refer to the following Help documents for more information, ArcMap: Uninstalling ArcGIS for Desktop and ArcMap: Installing ArcGIS for Desktop on your computer.
Solution or Workaround
Depending on the cause, use one of the following options to resolve the issue:
Add the path to the system PYTHONPATH variable:
The following steps describe how to add the path to the PYTHONPATH variable:
- Right-click My Computer > Properties.
- On the Control Panel Home sidebar, click the Advanced system setting option.
- In the System Properties window, open the Advanced tab, and click the Environment Variables button.
- Under the System variables section, highlight the PYTHONPATH variable, and click the Edit button.
- Enter the following path in the Variable value section.
C:\Program Files (x86)\ArcGIS\Desktop10.x\ArcToolbox\Scripts
- Click OK.
- Click OK on the Environment Variables window.
- Click OK on the System Properties window.
For more information, refer to the following Help document: Importing ArcPy: Paths and import.
Install ArcGIS Desktop and Python on the same drive. For more information, refer to the following Help document: ArcMap: Python, NumPy, and MatPlotlib.