pypsa
Python for Power Systems Analysis
What it is and what it does
PyPSA is an open-source framework for modeling and optimizing modern power and energy systems. It handles conventional generators with unit commitment, variable renewable generation (wind and solar), hydro-electricity, inter-temporal storage, and coupling between energy sectors (electricity, heat, hydrogen). The framework supports multiple analysis modes: economic dispatch for short-term market simulation, linear optimal power flow for least-cost dispatch respecting network constraints, capacity expansion planning for long-term infrastructure investment decisions, and stochastic optimization for uncertainty. It is built on pandas for data storage, scipy and numpy for linear algebra, linopy for optimization problem formulation, and networkx for network calculations.
PyPSA is designed for researchers, planners, and utilities who need transparent, fast analysis of large networks over long time series. It includes visualization via matplotlib, seaborn, and plotly, and supports both AC and DC power flow analysis with optional loss approximations. The framework scales well with problem size and provides extensive documentation with tutorials and examples.
Use it for:
- Model and optimize dispatch of a regional electricity grid with mixed renewable and conventional generation over a year of hourly data
- Plan long-term capacity expansion for generation, storage, and transmission infrastructure to meet decarbonization targets
- Analyze security-constrained optimal power flow to ensure system reliability under line outage contingencies
- Simulate integrated energy systems coupling electricity, heating, and hydrogen production with sector-specific technologies
- Explore near-optimal system configurations using modelling-to-generate-alternatives to understand feasible design trade-offs
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
PyPSA is a Python framework for optimizing and simulating power and energy systems, supporting economic dispatch, optimal power flow, capacity expansion planning, and sector-coupling with multiple energy carriers.
Yes. PyPSA is actively maintained, has no known vulnerabilities, uses a permissive MIT license, and installs with low friction. It is well-suited for power system research, planning, and operational analysis. Install it if you need to model or optimize energy systems at any scale from local microgrids to continental networks.
Install
pypsa on PyPI
pip
pip install pypsauv
uv add pypsapoetry
poetry add pypsaInstalling pypsa
Before you install
Low install friction with a pure-wheel distribution. Active maintenance with a release 48 days ago and last commit on 2026-08-14. Supports Python 3.11 through 3.14. Depends on 18 runtime packages including scipy, pandas, networkx, and linopy for optimization.
License in practice
MIT License permits unrestricted commercial and private use, modification, and distribution with minimal restrictions. You may use PyPSA in proprietary projects without licensing concerns.
Quickstart
import pypsa
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)
n.optimize()
n.plot()
Requires Python 3.11 or later. Optimization requires an external solver; HiGHS is installed by default, but Gurobi, FICO Xpress, GLPK, or CBC can be used.
Verify before relying
- Whether the default HiGHS solver is sufficient for your problem scale or if commercial solvers are needed for performance
- Specific solver compatibility and licensing requirements for your use case
Package facts
| License | MIT License Copyright (c) 2015-2026 PyPSA contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the… (full text in the JSON record) (permissive) |
| Python support | supports the current Python release (>=3.11) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 18 — numpy, scipy, pandas, xarray, netcdf4, linopy, matplotlib, plotly, pydeck, seaborn, geopandas, shapely, networkx, deprecation, validators, highspy, levenshtein, platformdirs |
| Maintenance | actively maintained — 48 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 106,863/month — #12,635 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pypsa-1.2.4-py3-none-any.whl
Tags
More Scientific/Engineering packages
NumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
pandaspandas provides fast, flexible data structures…
permissive · top 100 on PyPI
scipyscipy provides numerical algorithms for…
permissive · top 100 on PyPI
scikit-learnscikit-learn provides a comprehensive Python…
permissive · top 1,000 on PyPI
dilldill extends Python's pickle module to…
permissive · top 1,000 on PyPI
multiprocessMultiprocess is an enhanced fork of Python's…
permissive · top 1,000 on PyPI
pandapowerpandapower automates power system modeling,…
permissive · top 15,000 on PyPI
power-grid-modelPower Grid Model is a Python/C++ library for…
copyleft · top 15,000 on PyPI
opowerFetches historical and forecasted energy usage…
permissive · top 15,000 on PyPI
pyomoPyomo is a Python framework for formulating and…
permissive · top 5,000 on PyPI
forecast-solarAsynchronous Python client for fetching solar…
permissive · top 15,000 on PyPI
NREL-PySAMPySAM wraps NREL's System Advisor Model (SAM)…
permissive · top 15,000 on PyPI
joulescopeJoulescope is a Python driver for the…
permissive · top 15,000 on PyPI
amplpyamplpy is a Python interface to AMPL, an…
permissive · top 15,000 on PyPI
openbb-us-eiaIntegrates U.S. Energy Information…
agpl · top 15,000 on PyPI