The python components of SHTOOLS can be installed using the pip package manager.

Python package installer (pip)

The easiest way to install the Python components of SHTOOLS (pyshtools) is to use pip. On Linux and macOS architectures, the binary wheels can be installed by executing one of the following commands

pip install pyshtools
pip install --upgrade pyshtools  # to upgrade a pre-existing installation

If you wish to instead compile the archive yourself, first make sure that you have the required dependencies installed for the Fortran-95 components. On most linux distributions, this can be accomplished using

sudo apt-get install libblas-dev liblapack-dev g++ gfortran libfftw3-dev tcsh

or on macOS using brew

brew install fftw

(Note that SHTOOLS supports the use of any FFTW3-compatible library, such as Intel’s MKL). Then build from source using the command

pip install pyshtools --no-binary pyshtools

If you would like to modify the source code, you should clone the SHTOOLS repo:

git clone https://github.com/SHTOOLS/SHTOOLS.git

Once the repo is cloned, enter the directory, and use either the command

pip install .

to install pyshtools in the active Python environment lib folder, or

pip install -e .

to install the files in the current working directory and link them to the system Python directory.

To uninstall pyshtools from your system directory, use the command

pip uninstall pyshtools

Note that these commands will install only the Python version that corresponds to the version of pip being used. On some systems, it may be necessary to specify explicitly pip3.x.

Python dependencies

In order to use the most basic aspects of pyshtools, it will be necessary to install the python packages numpy, scipy, and matplotlib. Furthermore, [astropy(https://www.astropy.org/) is required for the planetary constants module, xarray is required for netcdf file support, and requests is required when reading files from urls. All of these packages should be installed automatically when installing pyshtools.

In addition to these packages, it will be necessary to install manually cartopy and/or pygmt in order to access the geographic projections of the plotting functions. Finally, the package palettable is required by one of the notebooks, and this is useful for providing access to a suite of scientific color maps.

Edit me