DatumEdge

The website of James Shaw, a PhD student researching numerical methods for the atmosphere at University of Reading

NetCDF and matplotlib basemap with Python 3

14 September 2014

Ubuntu 14.04 does not have packages for NetCDF-Python or the Matplotlib Basemap Toolkit for Python 3. However, both can be installed from source without too much difficulty.
  1. Install the prerequisite packages with
    sudo apt-get install python3-matplotlib python3-dev libnetcdf-dev libgeos-dev libhdf5-dev
  2. Download and extract NetCDF-Python and install it with
    sudo python3 setup.py install
  3. Download and extract Matplotlib Basemap Toolkit
  4. If you try and install it, you will see the error
    /usr/bin/ld: cannot find -lgeos
    To avoid this, symlink the libgeos shared object
    sudo ln -s /usr/lib/libgeos-3.4.2.so /usr/lib/libgeos.so
    Then install as before using
    sudo python3 setup.py install
To check the installation, try import both libraries at the Python 3 prompt: