Installation#
The following sections will guide you through the installation of CLIMADA and its dependencies.
Attention
We recommend to use a conda-based python environment manager such as Mamba or Conda for creating a suitable software environment to execute CLIMADA.
All following instructions should work on any operating system (OS), including in particular: Windows, macOS, and Linux.
Hint
If you need help with the vocabulary used on this page, refer to the Glossary.
Decide on Your Entry Level!#
Hint
When mentioning the terms “terminal” or “command line” in the following, we are referring to the “Terminal” apps on macOS or Linux and the “Miniforge Prompt” on Windows.
Depening on your level of expertise, we provide two different approaches:
If you have never worked with a command line, or if you just want to give CLIMADA a try, follow the simple instructions.
If you want to use the very latest development version of CLIMADA or even develop new CLIMADA code, follow the advanced instructions.
Both approaches are not mutually exclusive. After successful installation, you may switch your setup at any time.
Notes on the CLIMADA Petals Package#
CLIMADA is divided into two packages, CLIMADA Core (climada_python) and CLIMADA Petals (climada_petals). The Core contains all the modules necessary for probabilistic impact, averted damage, uncertainty and forecast calculations. Data for hazard, exposures and impact functions can be obtained from the CLIMADA Data API. Hazard and Exposures subclasses are included as demonstrators only.
Attention
CLIMADA Petals is not a standalone module and requires CLIMADA Core to be installed!
CLIMADA Petals contains all the modules for generating data (e.g., TC_Surge, WildFire, OpenStreeMap, …).
New modules are developed and tested here.
Some data created with modules from Petals is available to download from the Data API.
This works with just CLIMADA Core installed.
CLIMADA Petals can be used to generate additional data of this type, or to have a look at the tutorials for all data types available from the API.
Both installation approaches mentioned above support CLIMADA Petals. If you are unsure whether you need Petals, you can install the Core first and later add Petals in both approaches.
Warning
At the moment, not all package managers support both Core and Petals in both installation approaches. See the list below.
Install Environment Manager#
You will need to choose a suitable Python environment manager. If you have Python installed, Pip should be installed alongside it.
We highly recommend Mamba or Conda, as this supports both simple and advanced installations for both Core and Petals, and also installs a useful shell on Windows.
The tool mamba (see Conda as Alternative to Mamba) is available in the installer Miniforge:
Open the “Terminal” app, copy-paste the two commands below, and hit enter:
curl -L -O "https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh" bash Miniforge3-$(uname)-$(uname -m).sh
Accept the license terms.
You can confirm the default location.
Answer ‘yes’ when asked if if you wish to update your shell profile to automatically initialize conda. Do not just hit ENTER but first type ‘yes’
If at some point you encounter
command not found: mamba, open a new terminal window.If you encounter
Run 'mamba init' to be able to run mamba activate/deactivate ..., please runmamba init zshormamba init.
Download the Windows installer at the Install section from Miniforge.
Execute the installer. This will install Mamba and provide the “Miniforge Prompt” program as a command line replacement.
Python Versions#
CLIMADA is primarily tested against a supported Python version, but is allowed to run with others. If you follow the installation instructions exactly, you will create an environment with the supported version. Depending on your setup, you are free to choose another allowed version, but we recommend the supported one.
Supported Version |
|
Allowed Versions |
|
Simple Instructions#
These instructions will install the most recent stable version of CLIMADA without cloning its repository.
Open the command line. Create a new Conda environment with CLIMADA by executing
mamba create -n climada_env -c conda-forge climada
Activate the environment:
mamba activate climada_env
You should now see
(climada_env)appear in the beginning of your command prompt. This means the environment is activated.Verify that everything is installed correctly by executing a single test:
python -m unittest climada.engine.test.test_impact
Executing CLIMADA for the first time will take some time because it will generate a directory tree in your home/user directory. After a while, some text should appear in your terminal. In the end, you should see an “Ok”. If so, great! You are good to go.
Optional: Install CLIMADA Petals into the environment:
mamba install -n climada_env -c conda-forge climada-petals
Attention
On Windows, installing
climada-petalswith Conda/Mamba may be prohibited as it takes forever to resolve the dependency tree. In these cases, Pixi is often the only reliable fallback.
As an alternative to mamba Pixi can be used to install climada from conda-forge. Pixi is a modern package manager, based on Conda, that offers much faster dependency resolution.
Open the command line and create a new folder for your Pixi project:
pixi init climada_pixi
Add CLIMADA from
conda-forge:pixi add --manifest-path climada_pixi/pixi.toml climada
Verify that everything is installed correctly by executing a single test:
# the pixi way to activate an environment pixi shell --manifest-path climada_pixi/pixi.toml # execute the test python -m unittest climada.engine.test.test_impact # the pixi way to deactivate an environment exit
Executing CLIMADA for the first time in a pixi environment will take quite some time because it will generate a directory tree in your home/user directory. If this test passes, great! You are good to go.
Optional: Install CLIMADA Petals into the same Pixi environment:
pixi add --manifest-path climada_pixi/pixi.toml climada-petals
You can execute a script or program and include CLIMADA in the current environment like so:
uv run --with climada <script.py>
Start a JupyterLab session with CLIMADA installed by executing
uv run -w climada -w jupyterlab jupyter lab
Open the command line. It usually makes sense to install CLIMADA in a new virtual environment (venv). Choose a suitable
path/to/climada_venv, and create one there:python -m venv path/to/climada_venv
Activate the virtual environment.
source path/to/climada_venv/bin/activate
You should see
(climada_venv)at the beginning of your command line now.Install CLIMADA into the venv.
pip install climada
Note
To deactivate the venv, simply execute
deactivate
Advanced Instructions: Installing from Source#
For advanced Python users or developers of CLIMADA, cloning the CLIMADA repository and installing the package from source. Installing from source also allows you to switch branches.
If you are using a Linux OS, make sure you have
gitinstalled (Windows and macOS users are good to go once Conda is installed). On Ubuntu and Debian, you may use APT:apt update apt install git
Both commands will probably require administrator rights, which can be enabled by prepending
sudo.Create a folder for your code. We will call it workspace directory. To make sure that your user can manipulate it without special privileges, use a subdirectory of your user/home directory. Do not use a directory that is synchronized by cloud storage systems like OneDrive, iCloud or Polybox!
Open the command line and navigate to the workspace directory you created using
cd. Replace<path/to/workspace>with the path of the workspace directory:cd <path/to/workspace>
Clone CLIMADA from its GitHub repository. Enter the directory and check out the branch of your choice. The latest development version will be available under the branch
develop.git clone https://github.com/CLIMADA-project/climada_python.git cd climada_python git checkout develop
The following steps depend on your choice of package manager:
Warning
If you followed the Simple Instructions before, make sure you either remove the environment with:
mamba env remove -n climada_env
before you continue, or you use a different environment name for the following instructions (e.g. climada_dev instead of climada_env).
Create an Conda environment called
climada_envfor installing CLIMADA:mamba create -n climada_env "python=3.11.*"
Hint
Use the wildcard
.*at the end to allow a downgrade of the bugfix version of Python. This increases compatibility when installing the requirements in the next step.Note
You may choose any of the allowed Python versions from the list above.
Use the default environment specs in
env_climada.ymlto install all dependencies. Then activate the environment:mamba env update -n climada_env -f requirements/env_climada.yml mamba activate climada_env
Install the local CLIMADA source files as Python package using
pip:python -m pip install -e ./
Hint
Using a path
./(referring to the path you are currently located at) will instructpipto install the local files instead of downloading the module from the internet. The-e(for “editable”) option further instructspipto link to the source files instead of copying them during installation. This means that any changes to the source files will have immediate effects in your environment, and re-installing the module is only required when the dependencies change.Verify that everything is installed correctly by executing a single test:
python -m unittest climada.engine.test.test_impact
Executing CLIMADA for the first time will take some time because it will generate a directory tree in your home/user directory. If this test passes, great! You are good to go.
Create a local venv and synchronize it:
uv syncNote
uv will automatically install the local package in editable mode.
Create a virtual environment in the repository folder and activate it:
python -m venv .venv source .venv/bin/activate
Install CLIMADA into the environment:
python -m pip install -e ./
Hint
Using a path
./(referring to the path you are currently located at) will instructpipto install the local files instead of downloading the module from the internet. The-e(for “editable”) option further instructspipto link to the source files instead of copying them during installation. This means that any changes to the source files will have immediate effects in your environment, and re-installing the module is only required when the dependencies change.
Install Developer Dependencies (Optional)#
Building the documentation and running the entire test suite of CLIMADA requires additional dependencies, which are not installed by default. They are also not needed for using CLIMADA. However, if you want to develop CLIMADA, we strongly recommend you install them.
Dependency Groups#
The CLIMADA Python package defines the following dependency groups:
Dependency Group |
Includes Dependencies… |
|---|---|
|
for all developer needs (includes all others) |
|
for building the documentation files from in-source pydoc annotations |
|
for executing the tests |
Installation works as follows:
With the climada_env activated, enter the workspace directory and then the CLIMADA repository as above.
Then, tell Pip to install the dev dependency group:
python -m pip install --group dev
No action required. uv sync installs the dev dependency group by default.
To request (only) a specific group, execute
uv sync --group <group>
Activate the venv, and enter the workspace directory and then the CLIMADA repository as above.
Then, tell Pip to install the dev dependency group:
python -m pip install --group dev
Note
If your pip does not recognize the --group option, make sure you update to the latest version:
python -m pip install --upgrade pip
pre-commit#
We use pre-commit to install and run automated, so-called pre-commit hooks before a new commit. These ensure, e.g., that files are formatted correctly. Please refer to the guide on pre-commit hooks for information on how to use this tool.
In order to use the hooks defined in .pre-commit-config.yaml, you need to install pre-commit and its hooks first.
With the climada_env activated, move to the repository and execute
python -m pip install pre-commit
pre-commit install
uv supports running tools that are not part of the local Python environment. These tools can be downloaded and run when invoked, or installed when needed repeatedly. We use this function for installing pre-commit:
uv tool install pre-commit --with pre-commit-uv
pre-commit is now available as tool in your shell. Move to the repository and install the hooks:
pre-commit install
With the climada_venv activated, move to the repository and execute
python -m pip install pre-commit
pre-commit install
make#
Instructions for running the test scripts can be found in the Testing Guide.
For executing the pre-defined test scripts in exactly the same way as they are executed by the automated CI pipeline, you will need make to be installed.
No action required.
make is installed by default.
mamba install -n climada_env make
tbd
tbd
Install CLIMADA Petals (Optional)#
If you are unsure whether you need Petals, see the notes above.
To install CLIMADA Petals, we assume you have already installed CLIMADA Core with the advanced instructions above.
Open the command line and navigate to the workspace directory.
Clone CLIMADA Petals from its repository. Enter the directory and check out the branch of your choice. The latest development version will be available under the branch
develop.git clone https://github.com/CLIMADA-project/climada_petals.git cd climada_petals git checkout develop
The following steps depend on your choice of package manager:
Update the Conda environment with the specifications from Petals and activate it:
mamba env update -n climada_env -f requirements/env_climada.yml mamba activate climada_env
Install the CLIMADA Petals package:
python -m pip install -e ./
Petals currently cannot be installed from source with uv.
Petals currently cannot be installed from source with Pip.
Code Editors#
JupyterLab#
Install JupyterLab into the Conda environment:
mamba install -n climada_env -c conda-forge jupyterlab
Make sure that the
climada_envis activated (see above) and then start JupyterLab:mamba activate climada_env jupyter lab
JupyterLab will open in a new window of your default browser.
Start JupyterLab in the local environment without adding it to the dependencies:
uv run --with jupyterlab jupyter lab
When inside the CLIMADA repository folder, activate the venv and install JupyterLab:
source ./venv/bin/activate python -m pip install jupyterlab
Start JupyterLab:
jupyter lab
Visual Studio Code (VSCode)#
Basic Setup#
Download and install VSCode following the instructions on https://code.visualstudio.com/.
Install the Python and Jupyter extensions. In the left sidebar, select the “Extensions” symbol, enter “Python” in the search bar and click Install next to the “Python” extension. Repeat this process for “Jupyter”.
Open a Jupyter Notebook or create a new one. On the top right, click on Select Kernel, select Python Environments… and then choose the Python interpreter from the
climada_env.If you are not using Mamba, your Python environment is not known system-wide. To find your interpreter, open the VSCode in the folder where your repository or venv is located. VSCode should detect it then.
See the VSCode docs on Python and Jupyter Notebooks for further information.
Hint
Both of the following setup instructions work analogously for Core and Petals. The specific instructions for Petals are shown in square brackets: []
Workspace Setup#
Setting up a workspace for the CLIMADA source code is only available for advanced installations.
Open a new VSCode window. Below Start, click Open…, select the
climada_python[climada_petals] repository folder in your workspace directory, and click on Open on the bottom right.Click File > Save Workspace As… and store the workspace settings file next to (not in!) the
climada_python[climada_petals] folder. This will enable you to load the workspace and all its specific settings in one go.Open the Command Palette by clicking View > Command Palette or by using the shortcut keys
Ctrl+Shift+P(Windows, Linux) /Cmd+Shift+P(macOS). Start typing “Python: Select Interpreter” and select it from the dropdown menu. If prompted, choose the option to set the interpreter for the workspace, not just the current folder. Then, choose the Python interpreter from theclimada_env(or venv).
For further information, refer to the VSCode docs on Workspaces.
Test Explorer Setup#
After you set up a workspace, you might want to configure the test explorer for easily running the CLIMADA test suite within VSCode.
Note
Please install the additional test dependencies before proceeding.
In the left sidebar, select the “Testing” symbol, and click on Configure Python Tests.
Select “pytest” as test framework and then select
climada[climada_petals] as the directory containing the test files.Select “Testing” in the Activity Bar on the left or through View > Testing. The “Test Explorer” in the left sidebar will display the tree structure of modules, files, test classes and individual tests. You can run individual tests or test subtrees by clicking the Play buttons next to them.
By default, the test explorer will show test output for failed tests when you click on them. To view the logs for any test, click on View > Output, and select “Python Test Log” from the dropdown menu in the view that just opened. If there are errors during test discovery, you can see what’s wrong in the “Python” output.
For further information, see the VSCode docs on Python Testing.
Spyder#
Spyter Setup with Mamba (outdated)
Installing Spyder into the existing Conda environment for CLIMADA might fail depending on the exact versions of dependencies installed.
Therefore, we recommend installing Spyder in a separate environment, and then connecting it to a kernel in the original climada_env.
Follow the Spyder installation instructions. You can follow the “Conda” installation instructions. Keep in mind you are using
mamba, though!Check the version of the Spyder kernel in the new environment:
mamba env export -n spyder-env | grep spyder-kernels
This will return a line like this:
- spyder-kernels=X.Y.Z=<hash>
Copy the part
spyder-kernels=X.Y.Z(until the second=) and paste it into the following command to install the same kernel version into theclimada_env:mamba install -n climada_env spyder-kernels=X.Y.Z
Obtain the path to the Python interpreter of your
climada_env. Execute the following commands:mamba activate climada_env python -c "import sys; print(sys.executable)"
Copy the resulting path.
Open Spyder through the command line:
mamba activate spyder-env spyder
Set the Python interpreter used by Spyder to the one of
climada_env. Select Preferences > Python Interpreter > Use the following interpreter and paste the iterpreter path you copied from theclimada_env.
Apps for Working with CLIMADA#
To work with CLIMADA, you will need an application that supports Jupyter Notebooks. There are plugins available for nearly every code editor or IDE, but if you are unsure about which to choose, we recommend JupyterLab, Visual Studio Code or Spyder. It is easy to get confused by all the different softwares and their uses so here is an overview of which tools we use for what:
Use |
Tools |
Description |
Useful for |
|---|---|---|---|
Distribution / manage virtual environment & packages |
Recommended: Mamba Alternatives: Anaconda |
|
Climada Users & Developers |
IDE (Integrated Development Environment) |
Recommended: VSCode Alternatives: Spyder, JupyterLab, PyCharm, & many more |
|
Climada Users & Developers |
Git GUI (Graphical User Interface) |
GitHub Desktop, GitKraken |
|
Climada Developers |
Continuous integration (CI) server |
Jenkins |
|
Climada Developers |
FAQs#
Answers to frequently asked questions.
How to update CLIMADA?#
We recommend keeping CLIMADA up-to-date. To update, follow the instructions based on your installation type:
Simple Instructions#
mamba update -n climada_env -c conda-forge climada
If Petals is installed, you can also update it:
mamba update -n climada_env -c conda-forge climada_petals
No action required. If you have not locked your script dependencies, uv will always use the latest version.
With the venv activated, upgrade CLIMADA:
python -m pip install --upgrade climada
Advanced Instructions#
Move into your local CLIMADA repository and pull the latest version of your respective branch:
cd <path/to/workspace>/climada_python
git pull
Then, update the environment and reinstall the package:
mamba env update -n climada_env -f requirements/env_climada.yml
mamba activate climada_env
python -m pip install -e ./
The same instructions apply for CLIMADA Petals.
Note
In rare cases, updating the environment might fail after switching a branch because the dependency updates are incompatible. If this happens, create a new environment (see the advanced instructions).
uv sync
Activate the venv first.
python -m pip install -e ./
How to switch branches?#
This is only available for advanced installations from source.
If you want to check out or review a specific feature, you may want to switch to a Git branch other than develop.
To switch to a new branch, open a terminal and move to the CLIMADA repository.
Then fetch the latest changes from the remote, switch to the target branch, and update your local version:
cd <path/to/workspace>/climada_python
git fetch
git checkout <branch>
git pull
After switching, it is good practice to update your environment, as the dependency definitions might have been changed.
The above instructions also apply for CLIMADA Petals, but you have to cd into the climada_petals repository in the first step, of course.
Installing More Packages#
You might use CLIMADA in code that requires more packages than the ones readily available in the CLIMADA environment.
Prefer installing these packages via Conda, and only rely on pip if that fails.
The default channels of Conda sometimes contain outdated versions.
Therefore, use the conda-forge channel:
mamba install -n climada_env -c conda-forge <package>
Only if the desired package (version) is not available, go for pip:
mamba activate climada_env
python -m pip install <package>
If you need additional dependencies for a script or program, use -w/--with (possibly multiple times):
uv run --with <package> <script.py>
If you want to permanently add a package to your current environment without adding it to the CLIMADA dependencies, use uv pip:
uv pip install <package>
If you manage a downstream project, you can add a new dependency.
Activate the venv. Then use pip:
python -m pip install <package>
Upgrading Packages#
Occasionally, you might want to update packages and dependencies in your environment.
Use mamba update:
mamba update -n climada_env -c conda-forge <package>
Sync with upgrading specific packages:
uv sync -P <package>
Or with upgrading all packages:
uv sync --upgrade
Attention
Upgrading packages will change the uv.lock file.
Do not commit these changes unless you know what you are doing.
Before switching branches, you will have to revert these changes (and thus undo the upgrade):
git restore uv.lock
Activate the venv. Then use pip:
python -m pip install <package>
Verifying Your Installation#
If you are unsure if everything works as intended, try running all tests. This is only available for advanced setups!
Move into the CLIMADA repository, activate the environment and then execute the tests:
cd <path/to/workspace>/climada_python
mamba activate climada_env
make unit_test
make integ_test
Move into the CLIMADA repository and then execute the tests:
uv run -- make unit_test
uv run -- make integ_test
Move into the CLIMADA repository, activate the venv and then execute the tests:
cd <path/to/workspace>/climada_python
source .venv/bin/activate
make unit_test
make integ_test
Error: ModuleNotFoundError#
Something is wrong with the environment you are using. After each of the following steps, check if the problem is solved, and only continue if it is not:
If you are working with Conda or Pip, make sure you are working in the CLIMADA environment or venv. This is usually indicated by
(climada_env)(or the name you chose) in the beginning of your command line.mamba activate climada_env
source <path/to/venv>/bin/activate
Make sure your package manager is up-to-date.
Install the missing package manually. Follow the instructions for installing more packages.
If you reached this point, something is severely broken.
The last course of action is to delete your CLIMADA environment.
mamba deactivate mamba env remove -n climada_env
Then repeat the installation process.
Reinstall all packages:
uv sync --reinstall
The last course of action is to delete your venv.
deactivate rm -r <path/to/venv>
Then repeat the installation process.
Still no good? Please raise an issue on GitHub to get help.
Logging Configuration#
Climada makes use of the standard logging package.
By default, the “climada”-Logger is detached from logging.root, logging to stdout with
the level set to WARNING.
If you prefer another logging configuration, e.g., for using Climada embedded in another application,
you can opt out of the default pre-configuration by setting the config value for
logging.climada_style to false in the configuration file
climada.conf.
Changing the logging level can be done in multiple ways:
Adjust the configuration file
climada.confby setting a the value of theglobal.log_levelproperty. This only has an effect if thelogging.climada_styleis set totruethough.Set a global logging level in your Python script:
import logging logging.getLogger('climada').setLevel(logging.ERROR) # to silence all warnings
Set a local logging level in a context manager:
from climada.util import log_level with log_level(level="INFO"): # This also emits all info log messages foo() # Default logging level again bar()
All three approaches can also be combined.
Conda as Alternative to Mamba#
We experienced several issues with the default conda package manager lately.
This is likely due to the large dependency set of CLIMADA, which makes solving the environment a tedious task.
We therefore switched to the more performant mamba and recommend using it.
Error: operation not permitted#
Conda might report a permission error on macOS Mojave. Carefully follow these instructions: conda/conda#8440
No impf_TC Column in GeoDataFrame#
This may happen when a demo file from CLIMADA was not updated after the change in the impact function naming pattern from if_ to impf_ when CLIMADA v2.2.0 was released.
Execute
mamba activate climada_env
python -c "import climada; climada.setup_climada_data(reload=True)"
The What Now? (Glossary)#
You might have become confused about all the names thrown at you. Let’s clear that up:
- Terminal, Command Line
A text-only program for interacting with your computer (the old fashioned way). If you are using Miniforge on Windows, the program is called “Miniforge Prompt”.
- Conda
A cross-platform package management system. Comes in different varieties (distributions).
- Mamba
The faster reimplementation of the
condapackage manager.- Pixi
The much faster modern package manager based on
conda.- uv
A modern, fast Python package manager.
- Environment (Programming)
A setup where only a specific set of modules and programs can interact. This is especially useful if you want to install programs with mutually incompatible requirements.
- pip
The Python package installer.
- git
A popular version control software for programming code (or any text-based set of files).
- GitHub
A website that publicly hosts git repositories.
- git Repository
A collection of files and their entire revision/version history, managed by git.
- Cloning
The process and command (
git clone) for downloading a git repository.- IDE
Integrated Development Environment. A fancy source code editor tailored for software development and engineering.