Installation and Setup

Installation of Python

The easiest way is to install Python 3.12 from the Microsoft Store. After the installation, it should be available in VS Code right away.

Alternatively:

  1. Download Python version 3.12.X from Python 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 afterwards

  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 Pip getting started (can also be used generally for working with pip).

Installation of Git

  1. In order to work with version control management, you need to install Git

  2. Visit the Git Getting Started Page and …

  3. Install Git by downloading the Installer and clicking through the setup

  4. For Git steps/processes afterwards, have a look at the Git Workflow page

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 VSC Homepage and install it

  3. Configuration of User Settings by using the VSC profile . Click on it to download the zip file, unpack it and afterwards select the profile in “Settings” - “Profile”. This will install necessary and helpful extensions, apply formatting with the rules of Black Formatter and adjust settings according to our guidelines. You are able to switch between different profiles for various repositories and their own settings.

Cloning eELib Repository to your Local Workspace

  1. VSC

  2. Alternative: GitBash (or other Git programs, personal choice)

    $ git clone https://gitlab.com/elenia1/elenia-energy-library
    
  3. Afterwards follow the steps you will be guided through, as you probably need to give your username and password for Gitlab

Note

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

Setup 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. You can paste this into the terminal:

    python3.12 -m venv .venv --upgrade-deps
    .venv/scripts/activate
    python --version
    
    1. Fail: In case scripts can’t be executed, do

      Set-ExecutionPolicy Bypass -Scope CurrentUser -Force
      .venv/scripts/activate
      python --version
      
    2. Check: If successful, the prompt should now start with (.venv).

    3. Check: The printed version should be Python 3.12.X.

  4. Install eELib with requirements. While in the project root folder, you can paste this into the terminal:

    pip install -e .
    pre-commit install
    

Test successfull installation

You can test the functionality and correct installation by running a scenario shipped with the eELib

  • GUI: Open the file test_scenario_building.py in the examples folder and click on the Run sign in the upper right corner (Quick start typically with F5)

  • Or use the terminal:

    1. Open a new pwsh terminal (typically: Ctrl + Shift + ö).

    2. The root should be the repository’s root elenia-energy-library-eelib. Run:

    python examples/test_scenario_building.py