ArcGIS 10.3 自帶 Python 2.7.8 (NumPy 1.7.1),手動安裝 SciPy 0.13.3 和 scikit-learn 0.16.0 後,導入 sklearn 報錯:
ValueError: numpy.ufunc has the wrong size, try recompiling

NumPy ABI 不兼容:
PyUFuncObject)升級 NumPy 至兼容版本:
# 在 ArcGIS Python 環境中執行
pip install --upgrade numpy==1.9.1
pip install --upgrade scipy==0.15.1
# scikit-learn 0.16.0 可保留或重裝
pip install --upgrade scikit-learn
| scikit-learn | 最低 NumPy | 推薦 NumPy | 最低 SciPy |
|---|---|---|---|
| 0.16.x | 1.8.2 | 1.9.x | 0.13.3 |
| 0.17.x | 1.9.2 | 1.10.x | 0.14.0 |
| 0.18.x | 1.10.0 | 1.11.x | 0.15.1 |
python27 為獨立環境,勿污染系統 PythonC:\Python27\ArcGIS10.3\python.exe -m pip install ... 精確安裝# 安裝 Miniconda
conda create -n arcgis_ml python=2.7 numpy=1.9.1 scipy=0.15.1 scikit-learn=0.16.1
conda activate arcgis_ml
# 需使用 ArcPy 時:sys.path.append(r"C:\Program Files\ArcGIS\Desktop10.3\arcpy")
sklearn 導入 numpy.ufunc has the wrong size 經典報錯 = NumPy 版本過低導致 ABI 不兼容。升級 NumPy 至 1.9.1+、SciPy 至 0.15.1+ 即可解決。生產環境強烈建議使用 Conda 隔離環境,避免污染 ArcGIS 核心運行時。