This tutorial is meant to support the training activity on the web API that may occur in the ECMWF's classroom.
The API is developed in pure python and the latest version is made available via Python Package Index (PyPI)
Installing the web API
The API installation within the ECMWF premises can- On an classroom account
- On a mac/Linux notebook
- On a notebook with windows installed
Disabling the proxy settings
Retrieving data
Installing the web API on a classroom account
Enabling a virtual environment
Users do not have root access. In order to allow them to install python packages they have to setup a virtual environment.
To fully cover the topic of installing virtual environments, users can look at this tutorial Using virtual Python environment.
Users that want to permanently and quickly access the virtual environment have to create a file $HOME/.bashrc and put the following content in it.
# Use a sensible umask umask 022 # Place to keep your virtual environment export WORKON_HOME="$HOME/.virtualenvs" mkdir -p $WORKON_HOME # Use Python interpreter from /usr/local/apps python_home="/usr/local/apps/python/2.7.12-01" # Use our Python interpreter for virtualenvwrapper export VIRTUALENVWRAPPER_PYTHON="$python_home/bin/python" export VIRTUALENVWRAPPER_VIRTUALENV="$python_home/bin/virtualenv" export VIRTUALENVWRAPPER_VIRTUALENV_ARGS="--no-site-packages" . $python_home/bin/virtualenvwrapper.sh
Users that do not want to have the virtual environment to be available at each access they can use a different file e.g. use_environments.
The python version defined in the python_home environmental variable may change with time (new versions available).
To check which version are available: type module avail python and press enter
To be able to use one specific version, just type module load [your choiche] and then check if the virtualenv command is available.
With the python ready to use and the script with the configurations to execute the virtualenv command, we have to source the script to configure our shell and then install a virtual environment.
source ~/.bashrc # (or source use_environments) mkvirtualenv cdsapi # or add -p [path to python executable you wish to use it can be different from the one specified in the set up script] workon cdsapi