English

Error: ImportError: no module named WeightsUtilities

Error Message

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:

Error:   
ImportError: no module named WeightsUtilities

Cause

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.
Note:
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:

Option A
Add the path to the system PYTHONPATH variable:

The following steps describe how to add the path to the PYTHONPATH variable:
  1. Right-click My Computer > Properties.
  2. On the Control Panel Home sidebar, click the Advanced system setting option.
  3. In the System Properties window, open the Advanced tab, and click the Environment Variables button.
  4.  Under the System variables section, highlight the PYTHONPATH variable, and click the Edit button.
  5. Enter the following path in the Variable value section.
C:\Program Files (x86)\ArcGIS\Desktop10.x\ArcToolbox\Scripts
  1. Click OK.
  2. Click OK on the Environment Variables window.
  3. Click OK on the System Properties window.
For more information, refer to the following Help document: Importing ArcPy: Paths and import.

Option B
Install ArcGIS Desktop and Python on the same drive. For more information, refer to the following Help document: ArcMap: Python, NumPy, and MatPlotlib.

Related Information