Version 3.3.2

Python versions

As of version 3.3.0, cfunits works only with Python 3.6 or newer.

As of version 3.0.0, cfunits works for Python 3 only. (Version 1.9 of cfunits works for Python 2 and Python 3.)


To install cfunits and most of its dependencies (i.e. all except the UDUNITS library) run, for example:

Install as root, with any missing dependencies.
$ pip install cfunits
Upgrade as root, with any missing dependencies.
$ pip install cfunits --upgrade
Install as a user, with any missing dependencies.
$ pip install cfunits --user

To install cfunits without any of its dependencies then run, for example:

Install as root without installing any of the dependencies.
$ pip install cfunits --no-deps

See the documentation for pip install for further options.


To install from source:

  1. Download the cfunits package from

  2. Unpack the library (replacing <version> with the version that you want to install, e.g. 3.0.0):

    $ tar zxvf cfunits-<version>.tar.gz
    $ cd cfunits-<version>
  3. Install the package:

  • To install the cfunits package to a central location:

    $ python install
  • To install the cfunits package locally to the user in the default location:

    $ python install --user
  • To install the cfunits package in the <directory> of your choice:

    $ python install --home=<directory>


Tests are run from within the cfunits/test directory:

$ python


The cfunits package requires:

  • Python, version 3.6 or newer, including the latest version Python 3.9,

  • numpy, version 1.15 or newer,

  • cftime, version 1.5.0 or newer, and

  • UNIDATA UDUNITS-2 library, version 2.2.20 or newer.

    UDUNITS-2 is a C library that provides support for units of physical quantities. If the UDUNITS-2 shared library file ( on GNU/Linux or libudunits2.0.dylibfile on MacOS) is in a non-standard location then its directory path should be added to the LD_LIBRARY_PATH environment variable. It may also be necessary to specify the location (directory path and file name) of the udunits2.xml file in the UDUNITS2_XML_PATH environment variable, although the default location is usually correct. For example, export UDUNITS2_XML_PATH=/home/user/anaconda3/share/udunits/udunits2.xml. If you get an error that looks like assert(0 == _ut_unmap_symbol_to_unit(_ut_system, _c_char_p(b'Sv'), _UT_ASCII)) then setting the UDUNITS2_XML_PATH environment variable is the likely solution.

    UDUNITS is available via Anaconda with:

    $ conda install -c conda-forge udunits2=2.2.20


Some dependencies have dropped support for Python 3.6 for their newer versions, so it may be necessary to use at least Python 3.7 in combination with those.

In particular, this is known to be the case if you are using numpy at version 1.20 or above.

Code repository

The complete source code is available at