NumPy compatibility issue with QSWAT+ 3.1.2 on QGIS 3.44.8 (Python 3.12)

5 views
Skip to first unread message

Awel Seid

unread,
Mar 18, 2026, 1:35:15 PM (3 days ago) Mar 18
to QSWAT+
Dear Chris George and SWAT+ User Group,

I recently encountered a problem while trying to run QSWAT+ (version 3.1.2) on QGIS 3.44.8 (Solothurn) with Python 3.12 on Windows. The plugin failed to initialize with the following traceback:

2026-03-17T17:05:40     INFO    QSWAT+ failed to import HRUs: Traceback (most recent call last):
  File "...\QSWATPlus\QSWATPlus\QSWATPlusMain.py", line 55, in <module>
    from .hrus import HRUs
  File "...\qgis\utils.py", line 1100, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "...\QSWATPlus\QSWATPlus\hrus.py", line 50, in <module>
    from .polygonizeInC2 import Polygonize
  File "...\qgis\utils.py", line 1100, in _import
    mod = _builtin_import(name, globals, locals, fromlist, level)
  File "polygonizeInC2.pyx", line 1, in init QSWATPlus.polygonizeInC2
ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

The error indicates a binary incompatibility between the precompiled Cython extension `polygonizeInC2` and the installed NumPy version. Initially, NumPy was version 2.4.2 (later upgraded to 2.4.3 without success). The extension expected a data type size of 96, but the runtime NumPy reported 88. After some investigation, I found that downgrading NumPy to version 1.26.4 resolved the issue completely. The plugin now loads and functions as expected.

Environment details:
- QGIS version: 3.44.8 (Solothurn)
- QSWAT+ version: 3.1.2
- Python version: 3.12
- Operating System: Windows 11
- NumPy version (before fix): 2.4.3 → (after fix): 1.26.4

Possible cause:
The precompiled `.pyd` files (e.g., `polygonizeInC2.cp312-win_amd64.pyd`) were likely built against NumPy 1.x, which uses an older ABI. NumPy 2.x introduced ABI changes, leading to the size mismatch. Downgrading to NumPy 1.26.4 restores compatibility.

My request​:
If possible, could future releases of QSWAT+ include updated Cython extensions compiled against NumPy 2.x? Alternatively, providing a note in the installation instructions about the required NumPy version would help other users encountering the same issue.

Thank you for your excellent work on QSWAT+​. 

Best regards,  
Reply all
Reply to author
Forward
0 new messages