Honjo Naoki
Honjo Naoki

Reputation: 3

"from pyhdf.SD import SD, SDC" raises "ImportError: No module named '_hdfext'" and no one seems to know where "_hdfext" is

My system is Windows and Python3. I'd like to import pyhdf.SD, and I can import pyhdf successfully.
However, when I run from pyhdf.SD import SD, SDC, it raises

Traceback (most recent call last):
  File "C:\Users\usrname\AppData\Local\Programs\Python\Python39\lib\site-packages\pyhdf\hdfext.py", line 14, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\usrname\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
  File "<frozen importlib._bootstrap>", line 565, in module_from_spec
  File "<frozen importlib._bootstrap_external>", line 1173, in create_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
ImportError: DLL load failed while importing _hdfext: The specified module could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\usrname\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Users\usrname\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\__main__.py", line 39, in <module>
    cli.main()
  File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py", line 430, in main
    run()
  File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy/..\debugpy\server\cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "c:\program files\microsoft visual studio\2022\community\common7\ide\extensions\microsoft\python\core\debugpy\_vendored\pydevd\_pydevd_bundle\pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "C:\Users\usrname\source\repos\HDF\HDF\HDF.py", line 24, in <module>
    from pyhdf.SD import SD, SDC
  File "C:\Users\usrname\AppData\Local\Programs\Python\Python39\lib\site-packages\pyhdf\SD.py", line 1003, in <module>
    from . import hdfext as _C
  File "C:\Users\usrname\AppData\Local\Programs\Python\Python39\lib\site-packages\pyhdf\hdfext.py", line 17, in <module>
    _hdfext = swig_import_helper()
  File "C:\Users\usrname\AppData\Local\Programs\Python\Python39\lib\site-packages\pyhdf\hdfext.py", line 16, in swig_import_helper
    return importlib.import_module('_hdfext')
  File "C:\Users\usrname\AppData\Local\Programs\Python\Python39\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named '_hdfext'

I can find those who resolved the same issue however all those solutions are not helpful. For example, at this forum, the "_hdftext.so" file resolved the "No _hdfext" problem, however no one except the asking question could obtain it. Besides, I installed
numpy 1.26.4 (not latest because another module requires this)
hdf4lib 4.2.16-2
VisualStudioBuildTool2022
zlib
and They are the requirement for pyhdf which is showed on the official site but I can't install only libjpeg because I don't know how to install it and how it works. How can I get the missed the "_hdfext" file?

Any help will be greatly appreciated. Supplement:the "_hdfext" directory is not same with "hdfext" files such as "hdfext.i".

Upvotes: 0

Views: 193

Answers (0)

Related Questions