I'm trying to open HDF files using a python code provided in this website (https://hdfeos.org/software/pyhdf.php). However, I get an error while importing the pyhdf package
import os
from pyhdf.SD import SD, SDC
import numpy as np
import rasterio
The error :
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xf . Check the section C-API incompatibility at the Troubleshooting ImportError section at https://numpy.org/devdocs/user/troubleshooting-importerror.html#c-api-incompatibility for indications on how to solve this problem .
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
Input In [14], in <cell line: 2>()
1 import os
----> 2 from pyhdf.SD import SD, SDC
3 import rasterio
File ~\Miniconda3\lib\site-packages\pyhdf\SD.py:1003, in <module>
38 """
39 SD (scientific dataset) API (:mod:`pyhdf.SD`)
40 =============================================
(...)
999
1000 """
1001 import os, sys, types
-> 1003 from . import hdfext as _C
1004 from .six.moves import xrange
1005 from .error import _checkErr, HDF4Error
File ~\Miniconda3\lib\site-packages\pyhdf\hdfext.py:10, in <module>
8 # Import the low-level C/C++ module
9 if __package__ or "." in __name__:
---> 10 from . import _hdfext
11 else:
12 import _hdfext
ImportError: numpy.core.multiarray failed to import
I tried upgrading numpy and pyhdf versions but it didn't work
As commented by @Cow, I am posting this as an answer:
https://fhs.github.io/pyhdf/install.html#requirements
Pay special attention to Swig-generated interface files
SWIG should silently regenerate the two interface files, after which installation should proceed correctly.
https://fhs.github.io/pyhdf/install.html#swig-generated-interface-files