Installation¶
Version 3.3.3
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.)
pip¶
To install cfunits and most of its dependencies (i.e. all except the UDUNITS library) run, for example:
$ pip install cfunits
$ pip install cfunits --upgrade
$ pip install cfunits --user
To install cfunits without any of its dependencies then run, for example:
$ pip install cfunits --no-deps
See the documentation for pip install for further options.
Source¶
To install from source:
Download the cfunits package from https://pypi.org/project/cfunits
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>
Install the package:
To install the cfunits package to a central location:
$ python setup.py install
To install the cfunits package locally to the user in the default location:
$ python setup.py install --user
To install the cfunits package in the <directory> of your choice:
$ python setup.py install --home=<directory>
Dependencies¶
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 (
libudunits2.so.0
on GNU/Linux orlibudunits2.0.dylibfile
on MacOS) is in a non-standard location then its directory path should be added to theLD_LIBRARY_PATH
environment variable. It may also be necessary to specify the location (directory path and file name) of theudunits2.xml
file in theUDUNITS2_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 likeassert(0 == _ut_unmap_symbol_to_unit(_ut_system, _c_char_p(b'Sv'), _UT_ASCII))
then setting theUDUNITS2_XML_PATH
environment variable is the likely solution.UDUNITS is available via Anaconda with:
$ conda install -c conda-forge udunits2=2.2.20
Note
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.