pytroll / satpy

Python package for earth-observing satellite data processing
http://satpy.readthedocs.org/en/latest/
GNU General Public License v3.0
1.08k stars 298 forks source link

netcdf4 version causes error #2960

Closed thja-pml closed 3 weeks ago

thja-pml commented 3 weeks ago

Describe the bug The cf_writer checks nercdf4 lib versions and seems to accept those with 'dev' in the name but not 'development'.

To Reproduce Install the netcdf4 library with .netcdf4libversion 4.9.3-development Try to write out file

# Your code here

import satpy
from satpy.readers import FSFile
from pygac_fdr.config import read_config
from pygac_fdr.reader import read_gac

config = read_config(conf_file)
scene = read_gac(
    LAC_test, reader_kwargs=config["controls"].get("reader_kwargs")
)

writer = NetcdfWriter(
    output_dir=config["output"].get("output_dir"),
    global_attrs=config.get("global_attrs"),
    gac_header_attrs=config.get("gac_header_attrs"),
    fname_fmt=config["output"].get("fname_fmt"),
    encoding=config["netcdf"].get("encoding"),
    engine=config["netcdf"].get("engine"),
    debug=config["controls"].get("debug"),
)

writer.write(scene=scene)

Expected behavior The write fails due to a libnetcdf version error

Actual results File /conda_path/AVHRR_FCDR/lib/python3.10/site-packages/satpy/writers/cf_writer.py:395, in _get_backend_versions() 391 def _get_backend_versions(): 392 import netCDF4 393 return { 394 "netCDF4": Version(netCDF4.version), --> 395 "libnetcdf": Version(netCDF4.netcdf4libversion), 396 "xarray": Version(xr.version) 397 }

File /conda_path/AVHRR_FCDR/lib/python3.10/site-packages/packaging/version.py:200, in Version.init(self, version) 198 match = self._regex.search(version) 199 if not match: --> 200 raise InvalidVersion(f"Invalid version: '{version}'") 202 # Store the parsed out pieces of the version 203 self._version = _Version( 204 epoch=int(match.group("epoch")) if match.group("epoch") else 0, 205 release=tuple(int(i) for i in match.group("release").split(".")), (...) 211 local=_parse_local_version(match.group("local")), 212 )

InvalidVersion: Invalid version: '4.9.3-development

Screenshots If applicable, add screenshots to help explain your problem.

Environment Info:

Additional context Add any other context about the problem here.