在安装netcdf4是出现和hdf相关的报错,实际上我此前已经通过conda install hdf5安装了hdf库,但安装netcdf时还是找不到hdf5。 最终豆包给出了接近方案是可行的,方法是使用conda 同时安装hdf和netcdf,命令如下:
$conda install -c conda-forge hdf5 netcdf4==1.5.6
具体安装报错的表现:
(python38) [liucouhua_p@paraai-n32-h-01-ccs-master-2 pkgconfig]$ pip install netcdf4==1.5.6 -i https://pypi.tuna.tsinghua
.edu.cn/simple
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting netcdf4==1.5.6
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/79/0d/caa957cc1b42b718ce4b9b3e849e6f7aa99faad2d522d8f2d7a33500fba0/netCDF4-1.5.6.tar.gz (763 kB)
Preparing metadata (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py egg_info did not run successfully.
│ exit code: 1
╰─> [24 lines of output]
Package hdf5 was not found in the pkg-config search path.
Perhaps you should add the directory containing `hdf5.pc'
to the PKG_CONFIG_PATH environment variable
Package 'hdf5', required by 'virtual:world', not found
Traceback (most recent call last):
File "<string>", line 2, in <module>
File "<pip-setuptools-caller>", line 34, in <module>
File "/tmp/pip-install-h8yxcwoh/netcdf4_35a1603bf73d415886a3a05531df84d8/setup.py", line 441, in <module>
raise ValueError('did not find netCDF version 4 headers')
ValueError: did not find netCDF version 4 headers
reading from setup.cfg...
checking /home/bingxing2/ailab/liucouhua_p/.conda/envs/python38/include ...
HDF5 library version: 1.12.1 headers found in /home/bingxing2/ailab/liucouhua_p/.conda/envs/python38/include
HDF5 library version: 1.12.1 found in /home/bingxing2/ailab/liucouhua_p/.conda/envs/python38
NETCDF4_DIR environment variable not set, checking standard locations..
checking /home/bingxing2/ailab/liucouhua_p/.conda/envs/python38 ...
checking /home/bingxing2/ailab/liucouhua_p/.conda/envs/python38/Library ...
checking /home/bingxing2/ailab/liucouhua_p ...
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.