netcdf4-python
netcdf4-python copied to clipboard
"DLL load failed while importing _netCDF4" with netCDF-C 4.9.0 and HDF5 1.10.8
Version : netCDF4-python 1.6.2 OS: Windows 10 Python version: 3.11.1
I am trying to follow the steps from the page (https://unidata.github.io/netcdf4-python/#developer-install) to build netCDF4-Python v1.6.3 with netCDF-C and HDF5 that we build ourselves (instead of using the pip package manager).
Our netCDF-C version is 4.9.0, and we have linked it to HDF5 1.10.8. With these versions of netCDF-C and HDF5, the netCDF4-Python build goes fine but when I execute "import netCDF4", I see the following error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\abaruah\AppData\Local\Programs\Python\Python311\Lib\site-packages\netcdf4-1.6.2-py3.11-win-amd64.egg\netCDF4\__init__.py", line 3, in <module>
from ._netCDF4 import *
ImportError: DLL load failed while importing _netCDF4: The specified module could not be found.
I do not see the error and everything works fine if I download the netCDF-C v4.9.0 binaries from the following site (https://downloads.unidata.ucar.edu/netcdf/). Here, netCDF-C is built with HDF5 1.12.1.
Is there a requirement for the HDF5 version to be 1.12.1 or is HDF5 v1.10.8 not supported in netCDF-C v1.6.2? If not, can some help me to resolve this error?
Although you say the build went fine, something likely went wrong with either the build or install. I would suggest saving the output of the build and posting it here. HDF5 1.10.8 should work fine.
Please find the output of 'python setup.py build' and 'python setup.py install' in the two files build.log and install.log respectively. build.log install.log
Another thing I would like to mention is that for 'import netCDF4' to actually work, I have to copy the extracted binaries from the 'bin' folder (from the Unidata netCDF page) to the folder 'AppData\Local\Programs\Python\Python311\Lib\site-packages\netCDF4-1.6.2-py3.11-win-amd64.egg\netCDF4'. I get the errors I mentioned in the problem description if I copy the binaries from the bin folder of the netCDF-C v4.9.0 that I built (and not downloaded).
Even if I set the HDF5_DIR and NETCDF4_DIR env variables to the location of my netCDF binaries while building netCDF4-Python, 'import netCDF4' works only if I copy the Unidata binaries.
hopefully someone with some knowledge of building and installing python C extensions with C lib dependencies on windows will chime in - I have no clue. Curious why installing via pip or conda is not an option for you?
conda is not an option for us because of legal restrictions in our organization. We want to build from source (developer install) because we want to use netCDF4-Python with netCDF-C v4.9.0 and HDF5 v1.10.8. pip does not install these versions of netCDF-C and HDF5.
I am having the same issue when using conda:
File ~\AppData\Local\anaconda3\lib\site-packages\xarray\backends\api.py:566 in open_dataset
backend_ds = backend.open_dataset(
File ~\AppData\Local\anaconda3\lib\site-packages\xarray\backends\netCDF4_.py:590 in open_dataset
store = NetCDF4DataStore.open(
File ~\AppData\Local\anaconda3\lib\site-packages\xarray\backends\netCDF4_.py:358 in open
import netCDF4
File ~\AppData\Local\anaconda3\lib\site-packages\netCDF4\__init__.py:3
from ._netCDF4 import *
ImportError: DLL load failed while importing _netCDF4: The specified procedure could not be found.```
I am having the same issue when using conda
Please open an issue in the proper conda channel. If that is conda-forge it should be in https://github.com/conda-forge/netcdf4-feedstock
I am having the same issue when using conda
Please open an issue in the proper conda channel. If that is conda-forge it should be in https://github.com/conda-forge/netcdf4-feedstock
I am not sure it really is conda-forge since the version I have installed is 1.6.2, installed using conda install netcdf4
I am not sure it really is conda-forge since the version I have installed is 1.6.2, installed using conda install netcdf4
The template issue there will request some information that will help you sort that out. Just follow the instructions there.