Install Pylectra¶
Beginner
Prerequisites: Install Python, Install Git, What is a virtual environment
Pick your path¶
| Your goal | Recommended path |
|---|---|
| Just run pylectra, no source edits | Path 1: install from PyPI |
| Track latest code / read internals / patch bugs | Path 2: editable source install |
| Avoid git but want source code | Path 3: download zip |
All three start from a working Miniconda — see Install Python.
Path 1 — install from PyPI¶
# 1. Create a clean environment
conda create -n pylectra-env python=3.11 -y
conda activate pylectra-env
# 2. Install pylectra (core)
pip install pylectra
# 3. Recommended: also install the pandapower backend
pip install pylectra[pandapower]
Verify:
You should see a version number, e.g. 0.1.0.
Path 2 — editable source install¶
For users who want to read/modify source or contribute PRs.
# 1. Clone
git clone https://github.com/ZongjiaLong/Pylectra.git
cd pylectra
# 2. Create environment
conda create -n pylectra-dev python=3.11 -y
conda activate pylectra-dev
# 3. Install editable
pip install -e .
# 4. Optional extras
pip install -e ".[dev]" # pytest / ruff
pip install -e ".[docs]" # mkdocs documentation build
pip install -e ".[torch]" # torchdiffeq GPU solvers
pip install -e ".[all]" # everything (~2 GB)
-e . (editable) magic: edits to source files take effect on the next import pylectra — no reinstall needed.
Path 3 — download zip (no git)¶
- Open the pylectra Releases page.
- Pick the latest version, click Source code (zip).
- Unzip to a path without spaces or non-ASCII characters.
- From a terminal inside that directory:
cd path-to-unzipped/pylectra-0.1.0
conda create -n pylectra-env python=3.11 -y
conda activate pylectra-env
pip install -e .
Verify the install¶
Regardless of path, run these two:
# 1. Package imports
python -c "import pylectra; print('OK', pylectra.__version__)"
# 2. CLI works
python -m pylectra info
The second command lists every registered plugin — 12 categories, several dozen names. Seeing this means pylectra is fully wired up.
Install extra scientific packages¶
Subsequent tutorials use:
# conda is more reliable for binary-heavy packages
conda install -c conda-forge numpy scipy matplotlib pandas h5py pyarrow
# pandapower backend (already covered in Path 1; install separately for Path 2/3)
conda install -c conda-forge pandapower
# Jupyter Notebook (optional but very handy for interactive analysis)
conda install -c conda-forge jupyterlab
Smoke test¶
Path 1 users may not have an
examples/directory locally. Either switch to Path 2/3 to grab the source, or pull the YAMLs individually from the GitHub examples folder.
Expected: ~30 s of log output ending with:
That's your first successful simulation. Detailed walk-through in Your first simulation.
FAQ¶
Q: conda create raises an SSL error¶
Usually a mirror or proxy issue. Try:
Q: pip install pylectra hangs at "Building wheel for h5py..."¶
h5py needs the HDF5 C library. Install via conda first:
Q: pandapower won't install¶
The conda channel almost always works.
Q: How do I upgrade pylectra?¶
# Path 1 (PyPI)
pip install --upgrade pylectra
# Path 2 (source)
cd pylectra
git pull
pip install -e . # only needed if dependencies changed
Q: How do I uninstall completely?¶
conda activate pylectra-env
pip uninstall pylectra
conda deactivate
conda env remove -n pylectra-env # remove the whole environment
Next steps¶
- Your first simulation — run a case39 fault simulation and understand every YAML field.