Configure the python environment
Contents
Configure the python environment#
Some of code for the guidelines below are written in Python 3. It is recommended to use either the Miniconda3 (minimal Anaconda) or Anaconda3 distribution. The below instructions will be Anaconda specific (although relevant to any Python virtual environment), and assume the use of a bash shell.
A new Anaconda environment can be created using the conda environment management system that comes packaged with Anaconda.
In the following examples (related to the guideline on calculating SPI or SPEI), we will use an environment named climate_indices
(any environment name can be used instead of climate_indices
) which will be created and populated with all required dependencies through the use of the provided setup.py file.
This step must only be done the first time. Once the environment has been created there is no need to do it again.
Create new python environment#
First, open your Terminal (in your macOS/Linux and Ubuntu Linux on WSL), create the Python environment with
python3.7
as default:conda create -n climate_indices python=3.7
Proceed with
y
.The environment created can now be ‘activated’:
conda activate climate_indices
Install python package and additional software#
Install climate-indices package. Once the environment has been activated then subsequent Python commands will run in this environment where the package dependencies for this project are present. Now the package can be added to the environment along with all required modules (dependencies) via pip:
pip install climate-indices
Install netCDF Operator (NCO), Climate Data Operator (CDO) from Max-Planck-Institut für Meteorologie and Geospatial Data Abstraction Library (GDAL/OGR) using
conda
and proceed withy
.conda install -c conda-forge nco cdo gdal
For other analysis, we can create more general environemnt, As example, we will use an environment named gis
(any environment name can be used instead of gis
) which will be created and populated with all required dependencies through the use of the provided setup.py file.
Create other python environment#
First, open your Terminal (in your macOS/Linux and Ubuntu Linux on WSL), create the Python environment by typing below:
conda create -n gis
Proceed with
y
.The environment created can now be ‘activated’:
conda activate gis
Install python package and additional software#
Install additional package that might be required. Example:
conda install -c conda-forge python numpy scipy matplotlib nco cdo netcdf4 gdal rasterio xarray cartopy pandas geopandas jupyter