Installation and Setup
Installation and Setup of Python for working wit eELib
Download Python version 3.10.X from https://www.python.org/downloads/
When the download is finished, double-click the installer.
Select Install for all users and click Next >.
The default installation path is okay. Click Next >.
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.
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.
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
If needed, download VSC from the homepage and install it: https://code.visualstudio.com/
Configuration of User Settings
If not installed, install the Python Extension under Extensions (Ctrl + Shift + X)
Settings -> Extensions -> Python -> Formatting: Provider -> set to “black”
Settings -> Text Editor -> Formatting -> Format on Save should be true
Settings -> Features -> Notebook -> Format on Save should be true
Install the autoDocstring extension the same way as the Python Extension
Install the H5Web Extension for a quick look at the HDF5-Simulation-Output
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
For Git communication, have a look at the page Git Workflow
Clone the Git Repository with VSC: When all folders are closed, select Clone (Git) Repository
https-Address: “https://gitlab.com/elenia1/elenia-energy-library”
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
Open VSC and navigate to <Project Folder>
Open new Terminal: PowerShell is recommended (GitBash or Command Window are possible too, but not as mighty)
Create a virtual environment in the directory of your repository:
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
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 againIn 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)
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
If a new release of pip is available, you can update it via
python.exe -m pip install --upgrade pip
Check: If you open a Python file, the selected virtual environment is listed in the lower right corner in the blue row (‘.venv’)
Install Configurations for Processes, that are executed before each commit
Run
pre-commit install
Test successfull installation
- 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)
If you are not able to run the
test_scenario
and get the errorno 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>