threedi / hhnk-threedi-plugin

QGIS plugin gebruikt voor analyses van 3Di modellen bij HHNK.
1 stars 0 forks source link

h5py doesnt like gdal #88

Closed wvangerwen closed 11 months ago

wvangerwen commented 1 year ago

Fresh install of https://github.com/threedi/hhnk-threedi-plugin/blob/main/hhnk_threedi_plugin/env/environment_services.yml without spider using mambaforge results in broken imports,

Somehow still works currently on ota155 broken everywhere else.

Error: Importing h5py and gdal individually works fine. but after each other they do something with dll's.

>>> from osgeo import gdal
>>> import h5py
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Wietse\mambaforge\envs\threedipy\lib\site-packages\h5py\__init__.py", line 33, in <module>
    from . import version
  File "C:\Users\Wietse\mambaforge\envs\threedipy\lib\site-packages\h5py\version.py", line 15, in <module>
    from . import h5 as _h5
  File "h5py\h5.pyx", line 1, in init h5py.h5
ImportError: DLL load failed while importing defs: The specified procedure could not be found.

and the other way around

>>> import h5py
>>> from osgeo import gdal
Traceback (most recent call last):
  File "C:\Users\Wietse\mambaforge\envs\threedipy\lib\site-packages\osgeo\__init__.py", line 30, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\Wietse\mambaforge\envs\threedipy\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 _gdal: The specified procedure could not be found.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Wietse\mambaforge\envs\threedipy\lib\site-packages\osgeo\__init__.py", line 46, in <module>
    _gdal = swig_import_helper()
  File "C:\Users\Wietse\mambaforge\envs\threedipy\lib\site-packages\osgeo\__init__.py", line 42, in swig_import_helper
    raise ImportError(traceback_string + '\n' + msg)
ImportError: Traceback (most recent call last):
  File "C:\Users\Wietse\mambaforge\envs\threedipy\lib\site-packages\osgeo\__init__.py", line 30, in swig_import_helper
    return importlib.import_module(mname)
  File "C:\Users\Wietse\mambaforge\envs\threedipy\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 _gdal: The specified procedure could not be found.

On Windows, with Python >= 3.8, DLLs are no longer imported from the PATH.
If gdalXXX.dll is in the PATH, then set the USE_PATH_FOR_GDAL_PYTHON=YES environment variable
to feed the PATH into os.add_dll_directory().

Reproduce:

mamba env create --file environment_services.yml
conda activate threedipy
python
from osgeo import gdal
import h5py

Possibly to do with h5py being 3.8 while qgis 3.28.5 still uses h4py==2.10.0.

pip install h5py==2.10.0 doesnt work, cant build the wheels.

dependencies.py of ThreeDiToolbox -# On Windows, the hdf5 binary and thus h5py version depends on the QGis version -# QGis upgraded from hdf5 == 1.10.7 to hdf5 == 1.14.0 in QGis 3.28.6 QGIS_VERSION = Qgis.QGIS_VERSION_INT if QGIS_VERSION < 32806 and platform.system() == "Windows": SUPPORTED_HDF5_VERSIONS = ["1.10.7"] H5PY_DEPENDENCY = Dependency("h5py", "h5py", "==2.10.0", False) else: SUPPORTED_HDF5_VERSIONS = ["1.14.0"] H5PY_DEPENDENCY = Dependency("h5py", "h5py", "==3.8.0", True)

d2hydro commented 1 year ago
wvangerwen commented 11 months ago

Verse installatie met miniforge van environment_services.yml op de ota155 heeft een werkende Threedipy env opgeleverd.