I am trying to install netCDF4==1.4.2 using "pip install netCDF4==1.4.2" to use in jupyter notebook.
I am running
Windows 10 enterprise 64 bit.
python 3.10.9
anaconda-client 1.11.2
anaconda-navigator 2.4.0
anaconda-project 0.11.1
conda 23.3.1
conda-build 3.24.0
conda-content-trust 0.1.3
conda-pack 0.6.0
conda-package-handling 2.0.2
conda_package_streaming 0.7.0
conda-repo-cli 1.0.41
conda-token 0.4.0
conda-verify 3.4.2
ipykernel 6.19.2
ipython 8.10.0
ipython-genutils 0.2.0
ipywidgets 7.6.5
jupyter 1.0.0
jupyter_client 7.3.4
jupyter-console 6.6.2
jupyter_core 5.2.0
jupyter-server 1.23.4
jupyterlab 3.5.3
jupyterlab-pygments 0.1.2
jupyterlab_server 2.19.0
jupyterlab-widgets 1.0.0
pip 23.2
But, I am getting this error when using the Anaconda Prompt.
(base) C:\\Users\\79\>pip install netCDF4==1.4.2
Collecting netCDF4==1.4.2
Using cached netCDF4-1.4.2.tar.gz (769 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─\> \[19 lines of output\]
C:\\Users\\79\\AppData\\Local\\Temp\\pip-install-2bd1mj_1\\netcdf4_e3f1e4ce8f52415499486dd692dea5ae\\setup.py:170: DeprecationWarning: The SafeConfigParser class has been renamed to ConfigParser in Python 3.2. This alias will be removed in Python 3.12. Use ConfigParser directly instead.
config = configparser.SafeConfigParser()
Traceback (most recent call last):
File "\<string\>", line 2, in \<module\>
File "\<pip-setuptools-caller\>", line 34, in \<module\>
File "C:\\Users\\79\\AppData\\Local\\Temp\\pip-install-2bd1mj_1\\netcdf4_e3f1e4ce8f52415499486dd692dea5ae\\setup.py", line 371, in \<module\>
\_populate_hdf5_info(dirstosearch, inc_dirs, libs, lib_dirs)
File "C:\\Users\\79\\AppData\\Local\\Temp\\pip-install-2bd1mj_1\\netcdf4_e3f1e4ce8f52415499486dd692dea5ae\\setup.py", line 319, in \_populate_hdf5_info
raise ValueError('did not find HDF5 headers')
ValueError: did not find HDF5 headers
reading from setup.cfg...
HDF5_DIR environment variable not set, checking some standard locations ..
checking C:\Users\79 ...
checking /usr/local ...
checking /sw ...
checking /opt ...
checking /opt/local ...
checking /usr ...
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed
× Encountered error while generating package metadata.
╰─\> See above for output.
note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
I have tried suggestions in this post Installing specific package version with pip to no avail. And https://betterdatascience.com/pip-install-specific-version/. Which was basically updating setuptools, installing ez_isntall, and install unroll (which didn't work).
The same issue occurs if I try to install it through the settings in pycharm. Not too sure what is going on.
netCDF4
1.4.2 provides wheels for Python 2.7 and 3 up to 3.7. You have Python 3.10 so pip
is trying to compile netCDF4
from sources but that requires sources (esp. headers) for HDF5.
Either install HDF5 headers and libraries and compile netCDF4
. Or downgrade Python to 3.7, then pip
could use pre-compiled wheel from PyPI. Or use higher version of netCDF4
; netCDF4
1.5.8 and higher provide wheels for Python 3.10; the current latest version 1.6.4.