Installation and Setup

Installation of Python

  1. Download Python version 3.10.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

    1. Install some Extensions (Ctrl + Shift + X)

      • Python (for working with python programming language)

      • autoDocstring (for simple creation of docstrings for classes and methods)

      • H5Web (for a quick and easy view of the HDF5 simulation output)

      • Other possibly helpful extensions: Black Formatter, Git Graph, GitLens, Rainbow CSV

    2. Settings -> Editor: Default Formatter -> set to “Black Formatter”

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

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

    5. For max line lenght of 100 set: Settings -> Text Editor -> Rulers -> click “Edit in settings.json” and then set “‘editor.rulers’: [100]” (you can instantly see the vertical line shift to the right when saving the file)

Cloning eELib Repository to your Local Workspace

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

  2. You can also use GitBash (or other Git programs) for cloning (personal choice, up to you)

    $ 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:

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

      • For virtual environment path <_VENV-PATH_>, we typically use .venv (which for this tutorial we will now exemplarily do so)

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

    2. Run the activation script for Powershell: .venv\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

      • (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 (Quick start typicall possible with F5)

    • (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 <Project Folder>: Execute pip install -e.

    • Otherwise you have to insert the path: Execute pip install -e <Project Folder>