Install & Compatibility
Where this runs
tested against v1.3.12 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.380s · 90MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.6s · import 0.386s · 86MB
90MB installed
● package 90MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
CDF
✓ from cdflib import CDF
✗ from cdflib.cdf import CDF
CDF is a top-level class in cdflib, not a submodule.
cdf_to_xarray
✓ from cdflib import cdf_to_xarray
✗ from cdflib.xarray import cdf_to_xarray
cdf_to_xarray is a top-level function, not nested in an xarray submodule.
xarray_to_cdf
✓ from cdflib import xarray_to_cdf
✗ from cdflib.xarray import xarray_to_cdf
Same as cdf_to_xarray; both are top-level functions.
Open a CDF file, read global attributes, list variables, and read data for a variable.
from cdflib import CDF
cdf_file = CDF('example.cdf')
info = cdf_file.globalattsget()
print(info)
vars = cdf_file.cdf_info()
print(vars)
data = cdf_file.varget('variable_name')
print(data.shape)
cdf_file.close()
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'cdflib.cdf'
Incorrect import path; CDF is a class in the top-level cdflib package, not a submodule.
fixUse `from cdflib import CDF` instead.
AttributeError: module 'cdflib' has no attribute 'cdf_to_xarray'
Attempting to import cdf_to_xarray from a wrong location or missing install (e.g., without xarray dependency).
fixInstall xarray (`pip install xarray`) and import using `from cdflib import cdf_to_xarray`.
TypeError: 'numpy.float64' object cannot be interpreted as an integer
Passing a numpy float as start/count index to varget(). varget() expects Python ints.
fixCast to int: `start=int(start_val)` or use `varget('var', start=[int(s) for s in start])`. Upgrade
Version history
1.3.12latest on PyPI · released Jun 1, 2026
Audit
Dependencies
numpyrequiredcore dependency for array operations and CDF data type conversion
astropyoptionaloptional, used for time conversions and FITS compatibility
xarrayoptionaloptional, used for xarray integration (cdf_to_xarray, xarray_to_cdf)