Installing cf-python error


I am using a python virtual environment and have installed cf-python using pip install cf-python. When running import cf in spyder I receive the following message:

Traceback (most recent call last):

File “/tmp/ipykernel_18462/”, line 1, in <cell line: 1>
import cf

File “/home/thomas/Documents/Python/nemo_unagi/lib/python3.9/site-packages/cf/”, line 126, in
import cfunits

File “/home/thomas/Documents/Python/nemo_unagi/lib/python3.9/site-packages/cfunits/”, line 47, in
from .units import Units # noqa: F401

File “/home/thomas/Documents/Python/nemo_unagi/lib/python3.9/site-packages/cfunits/”, line 41, in
raise FileNotFoundError(

FileNotFoundError: cfunits requires UNIDATA UDUNITS-2. Can’t find the ‘udunits2’ library.

I can see in the directory of the virtual environment ‘lib/python3.9/site-packages/cfunits/etc’ that ‘udunits’ exists. Could you advise how I can go about making cf-python work?

I have even tried manually installing udunits in ‘site-packages’, but to no avail.


Hi Thomas,

Have you set LD_LIBRARY_PATH to point to the location of the ?


Hi Ros,

After some meddling about I’ve got it working. Instead of modifying LD_LIBRARY_PATH, I just made a symbolic link to the location of Happy days.


Hi Thomas,
Just in case someone else comes across this when searching on the helpdesk the method I use is to use a Miniconda install and do:
conda install -c conda-forge pip udunits2 cartopy
conda install cf-python cf-plot