{ "cells": [ { "cell_type": "markdown", "id": "5c1e8ad3", "metadata": { "tags": [] }, "source": [ "# Installation\n", "\n", "Please execute the instructions of the following text boxes in a Terminal or Anaconda Prompt. Chose an installation directory, e.g., the user's home directory. In the following it will be referred to as `$[installation directory]`.\n" ] }, { "cell_type": "markdown", "id": "fb641808-0a83-4b11-a2c6-2ea691d1efe9", "metadata": { "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ "## Install CLIMADA from sources\n", "\n", "### Download the latest version\n", "\n", "```bash\n", "cd $[installation directory]\n", "\n", "git clone https://github.com/CLIMADA-project/climada_python.git\n", "cd climada_python\n", "git checkout develop\n", "cd ..\n", "\n", "```\n", "\n", "### Set up the environment\n", "\n", "It's highly recommanded to install CLIMADA into a [Conda](https://docs.conda.io/projects/conda/en/latest/) environment. Without Conda, the installation of the dependencies can be cumbersome. If it is not already installed, download the latest version of [Anaconda](https://www.anaconda.com/) or [Miniconda](https://conda.io/miniconda.html) and execute it.\n", "\n", "Open a command prompt (Windows) or shell (Mac, Linux) and run:\n", "\n", "```bash\n", "conda env create -n climada_env -f climada_python/requirements/env_climada.yml\n", "conda activate climada_env\n", "```\n", "\n", "### Install the climada package\n", "\n", "Include the CLIMADA path into the Conda environment as follows:\n", "\n", "```bash\n", "pip install -e climada_python\n", "```\n", "\n", "With this setup, changes to CLIMADA's source code will immediately take effect. It removes the need to reinstall during development." ] }, { "cell_type": "markdown", "id": "7f94bbf8-5429-437c-8602-e11c79c92d40", "metadata": { "jp-MarkdownHeadingCollapsed": true, "tags": [] }, "source": [ "## Install CLIMADA from PyPi (alternative)\n", "\n", "Published releases of CLIMADA (not CLIMADA-petals) can also be installed from the PyPi repository https://pypi.org/project/climada/, since version 3.0.\n", "\n", "### Set up the environment\n", "\n", "Download the environment specification file from the git repository and save it locally, then create the conda environment:\n", "\n", "```bash\n", "wget https://github.com/CLIMADA-project/climada_python/raw/main/requirements/env_climada.yml\n", "conda env create -n climada_env -f env_climada.yml\n", "conda activate climada_env\n", "```\n", "\n", "If this was successful, `env_climada.yml` can be safely deleted.\n", "\n", "### Install the climada package\n", "\n", "```bash\n", "pip install climada\n", "```" ] }, { "cell_type": "markdown", "id": "5136859e-8b25-4719-a540-0f42339ccee8", "metadata": {}, "source": [ "## Install CLIMADA-petals (optional)\n", "\n", "### Download the latest version\n", "\n", "```bash\n", "cd $[installation directory]\n", "\n", "git clone https://github.com/CLIMADA-project/climada_petals.git\n", "cd climada_petals\n", "git checkout develop\n", "cd ..\n", "\n", "```\n", "\n", "### Update the environment\n", "\n", "It is possible that CLIMADA-petals has slightly different dependencies than CLIMADA-core, hence the conda environment should be updated.\n", "\n", "```bash\n", "conda env update -n climada_env -f climada_petals/requirements/env_climada.yml\n", "conda activate climada_env\n", "```\n", "\n", "### Install the climada_petals package\n", "\n", "Include the CLIMADA-petals path into the Conda environment as follows:\n", "\n", "```bash\n", "pip install -e climada_petals\n", "```\n", "\n", "In case of a separate environment for CLIMADA-petals, one needs to install the core package as well, either with the package from PyPi (`pip install climada`) or from local sources (`pip install -e climada_python`)" ] }, { "cell_type": "markdown", "id": "cf90fa87-cc4e-44be-ae1a-0c5d754316f1", "metadata": {}, "source": [ "## Test the installation\n", "\n", "Run the following command:\n", "\n", "```bash\n", "python -m unittest climada.engine.test.test_impact climada.engine.test.test_cost_benefit\n", "```\n", "\n", "If the installation has been successful, an OK will appear at the end (the execution shouldn't last more than 2 min).\n", "\n", "\n", "### Run tutorials\n", "\n", "In the *Home* section of Anaconda, with `climada_env` selected, install and launch `jupyter notebook`. A browser window will show up. Navigate to your ``climada_python`` repository and open ``doc/tutorial/1_main_CLIMADA.ipynb``. This is the tutorial which will guide you through all CLIMADA's functionalities. Execute each code cell to see the results, you might also edit the code cells before executing. See [tutorials](https://github.com/CLIMADA-project/climada_python/tree/main/doc/tutorial) for more information." ] }, { "cell_type": "markdown", "id": "b943087a-ca5b-4da2-bc04-9f9d491fcd5d", "metadata": {}, "source": [ "## Working with _Spyder_\n", "\n", "It is possible to use climada in combination with the [Spyder-IDE](https://www.spyder-ide.org/). However, depending on OS, CLIMADA version, Spyder version and installation tool, installing `spyder` into the `climada_env` environment may fail. In particular, MacOS and `conda install spyder` don't work well together. Although there are cases where `pip install spyder` bears satisfactory results, it is suggested to install `spyder` in a separate Conda environment and run it with the python interpreter from the `climada_env` environment instead. To do so, follow these instructions:\n", "\n", "- Start Anaconda, create a new python_env environment (just click create and enter the name, then press Create) and install latest Spyder in there (currently 4.2.5). Start this version of Spyder. After Spyder has started, navigate to *Preferences > Python Interpreter > Use the following interpreter* and paste the output of the following terminal command into the text box:\n", "\n", "```bash\n", "conda activate climada_env \n", "python -c \"import sys; print(sys.executable)\" \n", "# this returns a path, like /Users/XXX/opt/anaconda3/envs/climada_env/bin/python\n", "```\n", "\n", "\n", "- Obtain the version of the package `spyder-kernels` (currently 1.10.2) that has automatically been installed along with Spyder in the Anaconda environment and install the same version of `spyder-kernels` in the `climada_env` environment:\n", "\n", "```bash\n", "conda activate climada_env \n", "conda install spyder-kernels=1.10.2\n", "```\n", "\n", "- Start a new IPython console in Spyder and run ``tests_install.py``." ] }, { "cell_type": "markdown", "id": "9d550564-ddac-4b9a-a780-05274aa4321d", "metadata": {}, "source": [ "## FAQs\n", "\n", "* **ModuleNotFoundError**\n", " * the CLIMADA packages are not found. \\\n", " Check whether the climada environment is activated. If not, activate it (`conda activate climada_env`). Otherwise, the installation has failed. Try and follow the installation instructions above.\n", " * an external python library is not found. \\\n", " It might happen that the pip dependencies of `env_climada.yml` (the ones specified after ``pip:``) have not been installed in the environment `climada_env`.\n", " They can be installed manually one by one as follows:\n", " ```bash\n", " conda activate climada_env\n", " pip install library_name\n", " ```\n", " where ``library_name`` is the missing library.\\\n", " Another reason may be a recent update of the operating system (macOS). In this case removing and reinstalling Anaconda will be required.\n", "\n", "\n", "* **Conda permission error**\\\n", " (``operation not permitted``) in macOS Mojave: try the solutions suggested here [https://github.com/conda/conda/issues/8440](https://github.com/conda/conda/issues/8440)\n", "\n", "* **No 'impf\\_TC' column in GeoDataFrame**\\\n", " 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\\_' ([climada v2.2.0](https://github.com/CLIMADA-project/climada_python/releases/tag/v2.2.0)).\\\n", " To solve it, run `python -c 'import climada; climada.setup_climada_data(reload=True)` in a terminal.\n", "\n", "* **How to change the log level**\\\n", " By default the logging level is set to ``'INFO'``, which is quite verbose. This can be changed\n", "\n", " * through configuration, by editing the config file `climada.conf` (see Guide_configuration.ipynb) and setting the value of the ``global.log_level`` property.\n", " \n", " * programmatically, globally, in a script or interactive python environment (Spyder, Jupyter, IPython) by executing e.g.,\n", " ```python\n", " from climada.util.config import LOGGER\n", " from logging import WARNING\n", " LOGGER.setLevel(WARNING)\n", " ```\n", " \n", " * programmatically, context based, using `climada.util.log_level`:\n", " ```python\n", " from climada.util import log_level\n", " with log_level(level='WARNING'):\n", " quietly_do_something()\n", " ```\n" ] } ], "metadata": { "interpreter": { "hash": "927c67ab198fcb661784b2c362c65b0d20aa8c2be2fb72d3ff0a6f4e04b047d1" }, "kernelspec": { "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.12" } }, "nbformat": 4, "nbformat_minor": 5 }