Installation and Setup

Installation and Setup of Python for working wit eELib

  1. Download Python version 3.10.X from https://www.python.org/downloads/

  2. When the download is finished, double-click the installer.

  3. Select Install for all users and click Next >.

  4. The default installation path is okay. Click Next >.

  5. In the Customize Python page, click on the Python node and select Entire feature will be installed on local hard drive. Make sure that Add python.exe to Path is enabled. Click Next >.

    • If not, the Python Path has to be added to system variables by hand.

  6. When Windows asks you to allow the installation, do so. Wait for it to happen. Click Finish.

Note

This will also install the Python package manager pip. For checking and if not, see https://pip.pypa.io/en/stable/getting-started/ (can also be used generally for working with pip)

Installation and Setup of Python IDE (VSC)

Easier than using command window or PowerShell is the use of an IDE (integrated development environment) for Python, especially when working with the code.

  1. Decide for an IDE. There are several good options: PyCharm, Visual Studio Code, Jupyter Notebook, IDLE, Spyder, Pydev

    • We recommend Visual Studio Code (VSC) for eELib, so this tutorial will be based on VSC

  2. If needed, download VSC from the homepage and install it: https://code.visualstudio.com/

  3. Configuration of User Settings

    1. If not installed, install the Python Extension under Extensions (Ctrl + Shift + X)

    2. Settings -> Extensions -> Python -> Formatting: Provider -> set to “black”

    3. Settings -> Text Editor -> Formatting -> Format on Save should be true

    4. Settings -> Features -> Notebook -> Format on Save should be true

    5. Install the autoDocstring extension the same way as the Python Extension

    6. Install the H5Web Extension for a quick look at the HDF5-Simulation-Output

    7. For max line lenght of 100 set: Settings -> Editor -> Rulers -> click “Edit in settings.json” and then type “100” instead of the default “80” (you can directly see the vertical line shift to the right when saving the settings.json file

Cloning eELib Repository

  1. For Git communication, have a look at the page Git Workflow

  2. Clone the Git Repository with VSC: When all folders are closed, select Clone (Git) Repository

  3. You can also use GitBash for cloning (for some it seems easier)

    $ git clone https://gitlab.com/elenia1/elenia-energy-library
    

Note

The path to the project folder will now be noted as <Project Folder>.

Working in VSC with eELib

  1. Open VSC and navigate to <Project Folder>

  2. Open new Terminal: PowerShell is recommended (GitBash or Command Window are possible too, but not as mighty)

  3. Create a virtual environment in the directory of your repository:

    1. Run python -m venv <_VENV-PATH_>

      • For virtual environment path <_VENV-PATH_>, we typically use .venv

      • Accept VSC for acknowledging new environment, if it is detected

    2. Run the activation script for Powershell: .\<VENV-PATH>\Scripts\Activate.ps1

      • In case Scripts can’t be executed, you have to adjust the Execution Policy by running Set-ExecutionPolicy Bypass -Scope CurrentUser -Force and try again

      • In case you don’t use relative paths, the .\ at the beginning isn’t needed

      • (Command window has different activation file ‘activate.bat’)

      • Check: If successful, the prompt should now start with (.venv)

      • Check whether the correct python interpreter is selected: python --version (Output: Python 3.10.X)

  4. Install requirements into the virtual environment

    • If VSC explorer isn’t already in the repository folder, you have to navigate there

    • Run pip install -r requirements.txt

  5. If a new release of pip is available, you can update it via python.exe -m pip install --upgrade pip

  6. Check: If you open a Python file, the selected virtual environment is listed in the lower right corner in the blue row (‘.venv’)

  7. Install Configurations for Processes, that are executed before each commit

    • Run pre-commit install

Test successfull installation

  1. You can test the functionality and correct installation by running a testcase
    • Open the file test_scenario_building.py in the examples folder and click on the Run sign in the upper right corner

    • (Or run python test_scenario_building.py in the terminal)

  2. If you are not able to run the test_scenario and get the error no module named 'eelib'

    If your are in your local project path

    execute pip install -e.

    Otherwise you have to insert your local project path …

    execute pip install -e <local project path>