Cftime and netCDF4 version on windows

When we installed netCDF4, we got old version of cftime.

Creating this environment:

conda create -n junk python=3.9 netCDF4
# Name                    Version                   Build  Channel
netcdf4                   1.5.7            py39h3de5c98_1
# Name                    Version                   Build  Channel
cftime                    py39h080aedc_0

But cftime 1.6.2 exists,
If we do ‘conda update cftime’, it won’t update it.
But, ‘conda install cftime=1.6.2’ will upgrade cftime,

The following packages will be UPDATED:

  cftime             pkgs/main::cftime- --> conda-forge::cftime-1.6.2-py39hc266a54_1
  vs2015_runtime     pkgs/main::vs2015_runtime-14.27.29016~ --> conda-forge::vs2015_runtime-14.32.31332-h1d6e394_9

, and netcdf4 and cftime all work together with the new version.
Note the combination of netcdf4 and cftime is broken.

The following line of code doesn’t work:

time_2 = cftime.num2date(7020., 'minutes since 1999-11-25 00:00:00')
print('time_2XXXXX:  ', time_2)

the error message is shown below:

Traceback (most recent call last):
  File "C:\Users\leo.geng\learning_notes\PyGNOME_error_test\", line 12, in <module>
    time_2 = cftime.num2date(7020., 'minutes since 1999-11-25 00:00:00')
  File "src\cftime\_cftime.pyx", line 535, in cftime._cftime.num2date
  File "src\cftime\_cftime.pyx", line 379, in cftime._cftime.cast_to_int
TypeError: '<' not supported between instances of 'numpy.longdouble' and 'int'

This code will work if we update cftime to 1.6.2 version.

Note that the Channel column in the output from your conda create call is left blank.
This means the defaults channel is used. (defaults::cftime, i.e., pkgs/main::cftime is not yet updated to >=1.6)
If you want to install packages from conda-forge, you should give that channel higher priority (e.g., with the --channel=conda-forge CLI parameter) and/or only use one of conda-forge/defaults (via conda config --remove channels or conda config --set channel_priority strict or similar).

Thanks – we did notice that after posting – and channel priority was set to flexible.

If you install with -c conda-forge it does work.

However, I’m pretty sure is still didn’t work with channel priority strict – I’m not on Windows right now, so can’t check for sure.

And that’s an issue because we need to install a whole pile of stuff, most, but not quite all is available on conda-forge.

Still trying to understand the channel priority settings :frowning:

OK, more careful testing – if conda-forge is highest priority, and channel priority is strict, then it all works as expected.