Open-source project
PyPSA/PyPSA avatar
PyPSA/PyPSA

PyPSA: a Python power system framework that builds a linopy problem and hands it to HiGHS by default

PyPSA: Python for Power System Analysis

2,253 stars744 forksPythonMIT

At a glance

What is it?
PyPSA/PyPSA is an MIT-licensed Python framework for optimising and simulating power and energy systems. This review covers the analysis modes, the install commands, the solver choices, the pandas 3 floor and the load-flow limits, using the repository's own metadata.
Who is it for?
Use PyPSA if you are a researcher, planner or utility analyst with basic Python skills who needs transparent dispatch, capacity expansion or sector-coupling models that run on the free HiGHS solver. Look elsewhere if you need a point-and-click tool or an environment pinned to older pandas, since the package requires pandas 3.0 or newer and Python 3.11.
Can I use it commercially?
Yes. MIT is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly Python, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 23, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • PyPSA/PyPSA2,253 ★ · +73
Star history
Repository2026-10-082026-11-23
PyPSA/PyPSA2.2k2.3k

73 Stars in the last 46 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

Economic dispatch, linear OPF and the N-1 security-constrained variant share one network object

PyPSA stands for Python for Power System Analysis and is pronounced pipes-ah. It is an open-source Python framework for optimising and simulating modern power and energy systems, covering conventional generators with unit commitment, variable wind and solar, hydro-electricity, inter-temporal storage, coupling to other energy sectors, elastic demands, and linearised power flow with loss approximations in DC and AC networks.

Three analysis modes sit at the base. Economic Dispatch models short-term market-based dispatch with unit commitment, renewable availability, short-duration and seasonal storage including hydro reservoirs with inflow and spillage, load shedding and carrier conversion, using either perfect operational foresight or rolling horizon time resolution. Linear Optimal Power Flow extends it to respect network constraints in meshed AC-DC networks through a linearised representation of power flow (KVL, KCL) with optional loss approximations. Security-Constrained LOPF adds line outage contingencies to ensure reliability under N-1 conditions.

Capacity expansion, pathway planning, stochastic and MGA runs are separate problem types

Beyond dispatch, PyPSA supports least-cost long-term planning with investment decisions for generation, storage, conversion and transmission, handling single and multiple investment periods. Continuous and discrete investments are both supported.

Pathway Planning co-optimises several investment periods to plan transitions over time, with perfect planning foresight. Stochastic Optimisation implements a two-stage stochastic programming framework: scenario-weighted uncertain inputs, with investments as first-stage decisions and dispatch as recourse decisions. Modelling-to-Generate-Alternatives explores near-optimal decision spaces to show the range of feasible system configurations with similar costs.

The limit worth noting is the word perfect. Pathway planning assumes perfect planning foresight, so it describes a coordinated planner, not actors reacting to surprises. Treat its outputs as scenario analysis, and use the stochastic mode when uncertainty itself is the question.

Sector coupling treats heat pumps, electrolysers and vehicles as conversion links

Sector-Coupling models integrated energy systems with multiple carriers such as electricity, heat and hydrogen, plus conversion between them. The README names flexible representation of heat pumps, electrolysers, battery electric vehicles, direct air capture and synthetic fuels production.

For the reader, that means a model can include a hydrogen carrier alongside the grid without leaving the same Network object. The cost is model size. Adding carriers and storage multiplies variables, and PyPSA is described as designed to scale well with large networks and long time series, which is a design goal and not a benchmark. Run your own case on your own solver to see how it scales. The audience stated is researchers, planners and utilities with basic coding aptitude who need a fast, easy-to-use and transparent tool.

Pandas 3.0 and Python 3.11 are hard floors in pyproject.toml

Install with pip, conda or uv:

bash
pip install pypsa
bash
conda install -c conda-forge pypsa
bash
uv add pypsa

pyproject.toml sets requires-python to >=3.11 and lists classifiers for 3.11 through 3.14. The dependency list is the real constraint: pandas>=3.0, linopy>=0.9.0, geopandas>=0.9, networkx>=2 and pydeck>=0.6, plus numpy, scipy, pyarrow, xarray, netcdf4, matplotlib, plotly, seaborn, shapely and highspy. An environment pinned to pandas 2 cannot install this version. Optional extras add hdf5 (tables), cartopy, excel (openpyxl and python-calamine), gurobipy, cloudpath, dotenv and tsam. The project is marked Development Status 5, Production/Stable, and typed.

A model is a few n.add calls and one n.optimize call

The usage example creates a network, adds a bus, a load and a generator, loads a bundled example, optimises, plots and prints statistics:

py
import pypsa

# create a new network
n = pypsa.Network()
n.add("Bus", "mybus")
n.add("Load", "myload", bus="mybus", p_set=100)
n.add("Generator", "mygen", bus="mybus", p_nom=100, marginal_cost=20)

# load an example network
n = pypsa.examples.ac_dc_meshed()

# run the optimisation
n.optimize()

# plot results
n.generators_t.p.plot()
n.plot()

# get statistics
n.statistics()
n.statistics.energy_balance()

Note that the example reassigns n to the bundled ac_dc_meshed network, so the first network is discarded before n.optimize() runs. Component data and time series sit in pandas objects, such as the generators_t.p table that the plot call reads. The tree holds an examples/networks folder with sample data.

Because results come back as pandas tables, the next step after optimisation is ordinary dataframe work. The statistics call and the energy_balance accessor summarise the solved network without extra code, and the two plot calls give a time series of generator output and a network map. A model written this way stays readable to a colleague who knows pandas, which is the transparency the project advertises.

HiGHS ships by default, and Gurobi or Xpress are optional

PyPSA prepares the optimisation problem with linopy and can use different solvers. The free HiGHS solver is installed by default through the highspy dependency. GLPK and CBC are also named as free options, and commercial solvers such as Gurobi or FICO Xpress are supported, with free academic licenses available.

A gurobipy extra exists, so Gurobi users can install pypsa with that extra. Other solvers have to be installed separately. The consequence is that a first run works with no solver setup, while large problems that need a commercial solver mean installing and licensing it yourself. The README claims no solver speed ranking, so benchmark on your own network before paying for a license. For plotting, pandas, matplotlib, seaborn and plotly cover static and interactive output, with networkx used for network calculations.

Load flow uses Newton-Raphson, and maintenance is led from TU Berlin

Static Power Flow Analysis computes both full non-linear and linearised load flows for meshed AC and DC grids with the Newton-Raphson method. Optimisation modes use the linearised representation, so the non-linear flow is a separate calculation you run on purpose.

PyPSA has many contributors, with maintenance led by the Department of Digital Transformation in Energy Systems at the Technical University of Berlin. The project is currently supported by the German Research Foundation under grant number 528775426. Earlier versions were developed at the Karlsruhe Institute of Technology and at FIAS. The latest releases are v1.4.0 on 2026-10-09, v1.3.0 on 2026-08-19 and v1.2.4 on 2026-06-27. The repository is not archived and the last push was on 2026-10-23. The license is MIT, and documentation lives at docs.pypsa.org with tutorials, user guides, examples and an API reference.

Editorial conclusion

Use PyPSA if you are a researcher, planner or utility analyst with basic Python skills who needs transparent dispatch, capacity expansion or sector-coupling models that run on the free HiGHS solver. Look elsewhere if you need a point-and-click tool or an environment pinned to older pandas, since the package requires pandas 3.0 or newer and Python 3.11. Before starting a large model, check that your solver choice and Python version match the requirements in pyproject.toml.

Frequently asked questions

What is PyPSA?

PyPSA stands for Python for Power System Analysis, pronounced pipes-ah. It is an open-source Python framework for optimising and simulating modern power and energy systems.

How do I install PyPSA?

Run pip install pypsa, conda install -c conda-forge pypsa, or uv add pypsa. It requires Python 3.11 or newer.

Is PyPSA free?

Yes, the framework is open source under the MIT license. The free HiGHS solver is installed by default, and commercial solvers like Gurobi or FICO Xpress offer free academic licenses.

Official sources

  1. License: MIT
  2. Project website
  3. PyPSA/PyPSA on GitHub
  4. README
  5. Releases
Add this badge to your README

If you maintain this project, the badge below links readers to this analysis and shows its maintenance status from the daily GitHub snapshot. Paste the markdown into your README; add ?metric=license or ?metric=stars to the image URL for a different field.

Add this badge to your README

markdown
[![Hysen Labs](https://hysenlabs.com/badge/pypsa-pypsa.svg)](https://hysenlabs.com/projects/pypsa-pypsa)

Star history chart for your README

markdown
[![Star history](https://hysenlabs.com/chart/pypsa-pypsa.svg)](https://hysenlabs.com/projects/pypsa-pypsa)

Was this useful?