Skip to main content

PyPI version Documentation Status Python

IRENA FlexTool logo

IRENA FlexTool is an energy and power systems model for understanding the role of variable power generation in future energy systems. It performs capacity expansion planning as well as operational planning.

What's new

  • A lot faster. The model build and pre-processing now run as pure Python instead of the previous GLPSOL-based text pre-processing and AMPL-style model translation. There is no LP file written to disk and re-read between build and solve.
  • Automatic problem scaling. The polar-high matrix layer automatically scales the optimisation problem before it reaches the solver. Better numerical conditioning often speeds up the HiGHS solve considerably — sometimes dramatically — so total run time usually improves well beyond the faster build alone. The solver is still HiGHS; the gain comes from handing it a better-conditioned problem.
  • A new, easy-to-use interface. The FlexTool GUI is a standalone application (python -m flextool.gui) that manages projects and input sources, runs scenarios, and lets you browse the results — a result viewer reads outputs directly and supports single-scenario, scenario-comparison, and network-graph views with keyboard navigation. See the FlexTool GUI guide.
  • Spine Toolbox is still a parallel interface. Advanced users who build multi-tool workflows or integrate FlexTool with other models can keep using the Spine Toolbox workflow.
  • The same model and data. Existing input databases continue to work; the change is in how the matrix is generated and solved, not in the model formulation.

This is IRENA FlexTool v4 (see the current version in CHANGELOG.md). Report any bugs or difficulties in the issue tracker; ask modelling and usage questions in GitHub Discussions. The previous version of IRENA FlexTool can be found in https://www.irena.org/energytransition/Energy-System-Models-and-Data/IRENA-FlexTool.

Under the hood: Rust-based matrix generation

FlexTool is a thin Python layer over a Rust engine. It reads its input data and builds the optimisation matrix as polars DataFrames via polar-high, then solves with HiGHS. Variables and parameters are polars frames, so multiplications become joins and aggregations become group-bys — the heavy coefficient work runs inside polars' Rust core rather than as per-coefficient Python objects, and the matrix goes straight to HiGHS through highspy with no intermediate LP/MPS file. polar-high is a general-purpose, domain-free modelling layer published separately (Apache-2.0, pip install polar-high); it also applies the automatic problem scaling noted above, and its benchmark compares it against linopy and Pyomo on the same HiGHS solver.

Installation

Check your Python (and possibly install it)

FlexTool requires Python 3.11+, 64-bit Windows 10 or 11, Linux or macOS, and on Intel/AMD computers a processor with SSE4.2 and POPCNT (x86-64-v2: Intel Core i3/i5/i7 from 2009 on, AMD FX or Ryzen; not Core 2 or Phenom II). A processor with AVX2 (most from 2013 on) runs the fastest build. Windows 7 and 8.1 cannot run FlexTool 4. If a library reports "DLL load failed" on Windows, install the Microsoft Visual C++ Redistributable (x64, https://aka.ms/vs/17/release/vc_redist.x64.exe).

Open a terminal (Windows: Command Prompt or PowerShell; macOS: Terminal; Linux: your shell) and check which Python you have:

Platform Command
Windows py --version (falls back to python --version)
macOS / Linux python3 --version

The output looks like Python 3.12.4. If the command is not found, prints something below 3.11, or (on Windows) opens the Microsoft Store, install Python from https://www.python.org/downloads/ — on Windows tick "Add python.exe to PATH" in the installer. Then close and reopen the terminal so the new PATH takes effect.

On Windows, use py in place of python in the commands below if python is not recognised. If several versions are installed, py -3.11 --version (or -3.12, …) picks a specific one, and py -0 lists them all. On macOS/Linux, python often means Python 2 or does not exist at all, so use python3. Inside an activated virtual environment, plain python always means that environment's Python on every platform.

Install FlexTool into a virtual environment to keep its packages separate from other Python applications. If you want to install into the base Python (perhaps because you do not otherwise use Python), just run the last pip install command from below.

python -m venv .venv        # Windows: py -m venv .venv
                            # macOS/Linux: python3 -m venv .venv
# activate — Windows PowerShell:  .\.venv\Scripts\Activate.ps1
#            Windows CMD:         .\.venv\Scripts\activate.bat
#            Linux / macOS:       . .venv/bin/activate
python -m pip install --upgrade pip
pip install "flextool[toolbox,viewer]"

The [toolbox,viewer] extras add the Spine Toolbox database editor (for editing and viewing input and result databases) and the network-graph result view. To install without Spine Toolbox (edit/view data in a spreadsheet only), you can use plain pip install flextool.

On a processor without AVX2 (for example a Celeron/Pentium laptop up to about 2021, an Intel Core from before 2013 or an AMD FX), add the compat extra: pip install "flextool[toolbox,viewer,compat]". It installs the compatible build of the polars data library, which is about 10-30% slower but runs on any x86-64-v2 processor. When FlexTool finds such a processor without the compatible build, it says why and gives the pip command: in a terminal it asks "Run it now? [y/N]" and installs only on yes; without a terminal (a Spine Toolbox tool, CI) it stops with that message; the GUI asks at startup, before it loads polars (in its terminal, or in a yes/no dialog from a shortcut), and flextool-update installs it. python -m flextool.env_check reports what it found.

Your prompt should now show (.venv). Verify with python --version — it should report 3.11 or newer.

(If PowerShell blocks the activate script, run once per user: Set-ExecutionPolicy -Scope CurrentUser RemoteSigned.)

Launch the FlexTool GUI:

flextool

— equivalently python -m flextool.gui. The GUI creates and manages your projects and input databases; to seed the bundled template and example databases (handy for the CLI or Spine Toolbox workflows) run flextool-update.

Install from source (developers / latest main)

To participate in FlexTool development — or to run the not-yet-released main — clone the repo and install it editable:

git clone https://github.com/irena-flextool/flextool.git
cd flextool
python -m venv .venv
.\.venv\Scripts\Activate.ps1     # Linux / macOS:  . .venv/bin/activate
python -m pip install --upgrade pip
pip install -e .

The editable install picks up source changes on git pull; re-run pip install -e . only when a dependency pin in pyproject.toml changes.

Update FlexTool:

# If using virtual environment (venv), then activate venv first:
#   Windows PowerShell:  .\.venv\Scripts\Activate.ps1
#   Windows CMD:         .\.venv\Scripts\activate.bat
#   Linux / macOS:       . .venv/bin/activate
pip install --upgrade flextool

Documentation and installation

Metadata

Release files for flextool 4.7.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flextool 4.7.2
File Size Uploaded Provenance Actions
flextool-4.7.2.tar.gz 5.5 MB With provenance Details for flextool-4.7.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for flextool 4.7.2
File Interpreter ABI Platform Actions
flextool-4.7.2-py3-none-any.whl Python 3 none any Details for flextool-4.7.2-py3-none-any.whl

Total release size: 11.0 MB

Release files / flextool-4.7.2.tar.gz

Download URL flextool-4.7.2.tar.gz
Size 5.5 MB
Tags Source
SHA-256 checksum
How to use checksums
d17fa1c7794f0d2b28a677d240e2c0f6e82e4c6656cf5f66e833e3370cdb5ae7
BLAKE2b-256 checksum
How to use checksums
5a65468d071eb25ecf04f55080607743e41b54de25950d731c0f0d137056af7e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Release files / flextool-4.7.2-py3-none-any.whl

Download URL flextool-4.7.2-py3-none-any.whl
Size 5.5 MB
Tags Python 3
SHA-256 checksum
How to use checksums
4ebba5dfdab55217d8f373fa6ea9b50ca0d1680e47cad1c0bffb1b1008e1daeb
BLAKE2b-256 checksum
How to use checksums
f47980d31a640e6fc6d4907a4ca9692e67372d9036011d9874509f893e191dfb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

Security for flextool 4.7.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for flextool-4.7.2.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 27, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page