In my case I was using both xarray and netCDF, the issue was created by importing xarray before netCDF4.
Swapping the order fixed the issue.