python rasterio and geoh5py incompatible

32 views Asked by At

Python 3.9 environment, I need to importh both geoh5py and rasterio, they are not compatible, all good if I only need to import geoh5py plus other libs, or only rasterio plus other libs, but if import both of them, regardless of order of import, it will give me an error:

import rasterio
import geoh5py

Error:

from rasterio._base import gdal_version    
ImportError: DLL load failed while importing _base: The specified procedure could not be found.

or if import geoh5py first

from geoh5py.workspace import Workspace
     from . import _errors
ImportError: DLL load failed while importing _errors: The specified procedure could not be found.
2

There are 2 answers

0
Milap On

Try creating a new virtual environment and installing the packages with pip. This often helps with dependency issues. Here's how you can do it:

  1. Create a new virtual environment:
python -m venv venv
  1. Activate the virtual environment:
  • On Windows:
venv\Scripts\activate
  • On Mac/Linux:
source venv/bin/activate
  1. Install rasterio and geoh5py using pip:
pip install rasterio geoh5py
0
Barry On

my current working solution is to install via pipwin

pip install pipwin
pipwin install goal
pipwin install rasterio
pip install geoh5py

and all other libraries, this allows to import all packages successfully.