Troubleshooting#
Common issues and their solutions.
Installation Issues#
Conda Environment Creation Fails#
Symptom: Error during conda env create
Solutions:
Update conda first:
conda update -n base conda
Try mamba (faster resolver):
conda install -n base mamba mamba env create -f envs/pypsa-gb.yaml
Clear package cache:
conda clean --all
Gurobi License Not Found#
Symptom: GurobiError: No Gurobi license found
Solutions:
Check license file location:
Windows:
C:\Users\<username>\gurobi.licLinux/Mac:
~/gurobi.lic
Regenerate license (if academic):
grbgetkey YOUR-LICENSE-KEYUse HiGHS instead:
solver: name: "highs"
Snakemake Not Found#
Symptom: snakemake: command not found
Solutions:
Ensure environment is activated:
conda activate pypsa-gb which snakemake
Reinstall snakemake:
conda install -n pypsa-gb snakemake
Workflow Issues#
“Missing Input Files”#
Symptom: Snakemake reports missing input files
Solutions:
Check the file exists:
ls path/to/expected/fileGenerate the missing file:
snakemake path/to/missing/file -j 1
Check for typos in scenario name
Rule Fails with Exit Code 1#
Symptom: Rule fails, exit code 1
Solutions:
Check the log file:
cat logs/<rule_name>/<scenario>.logRe-run with verbose output:
snakemake target.nc -j 1 --verbose
Check Python errors in log
“No Rule to Produce Target”#
Symptom: No rule to produce <target>
Solutions:
Check target filename matches pattern
Verify scenario is defined in
scenarios.yamlCheck for wildcards mismatch
Network Issues#
All Generators at Same Bus#
Symptom: All generators mapped to one bus (e.g., INDQ41)
Cause: Coordinate system mismatch (WGS84 vs OSGB36)
Solution: The issue is in spatial mapping. Check:
from scripts.spatial_utils import detect_coordinate_system
# Check bus coordinates
print(detect_coordinate_system(network.buses[['x', 'y']]))
# Should output: 'OSGB36'
Network Not Connected#
Symptom: Isolated buses, disconnected regions
Solution:
import pypsa
n = pypsa.Network("resources/network/my_network.nc")
# Check connectivity
from pypsa.topology import find_disconnected_buses
disconnected = find_disconnected_buses(n)
print(f"Disconnected buses: {disconnected}")
Negative Line Impedance#
Symptom: Warnings about negative impedance
Solution: Usually data issue. Check raw network files for data entry errors.
Solver Issues#
Infeasible Optimization#
Symptom: Solver returns “infeasible” or “unbounded”
Causes & Solutions:
Demand exceeds supply:
n = pypsa.Network("resources/network/pre_solve.nc") print(f"Generation: {n.generators.p_nom.sum()/1000:.1f} GW") print(f"Peak demand: {n.loads_t.p_set.sum(axis=1).max()/1000:.1f} GW")
Network disconnected: See above
Zero capacity lines:
print(n.lines[n.lines.s_nom == 0])
Missing generators: Check if integration ran correctly
Solver Runs Forever#
Symptom: Solver doesn’t converge
Solutions:
Add time limit:
solver: TimeLimit: 3600 # 1 hour
Use barrier method:
solver: method: 2 crossover: 0
Reduce problem size:
Use reduced network
Shorten solve period
Cluster network
Out of Memory#
Symptom: Process killed, memory error
Solutions:
Reduce parallel jobs:
snakemake target.nc -j 1
Use network clustering
Reduce timesteps:
solve_period: start: "2035-01-01" end: "2035-01-02" # Shorter period
Market Dispatch Issues#
ELEXON Prices Requested For A Future Scenario#
Symptom: Market solve errors when bid_offer_source: "elexon" is used for
a modelled year after 2024.
Solution: ELEXON bid/offer data is historical. Use derived prices for future scenarios:
market:
balancing:
bid_offer_source: "derived"
Or use bid_offer_source: "auto" to prefer ELEXON only when valid historical
files are available.
Balancing Solve Is Infeasible#
Symptom: Wholesale solves, but solve_balancing_mechanism fails.
Common causes:
BM participation filters exclude assets needed for feasibility
non-participants are set to
behavior: "fixed"interconnector or outage settings over-constrain the physical network
Start from permissive participation settings, then tighten filters:
market:
balancing:
participation:
generators:
mode: "all"
behavior: "priced_out"
storage_units:
mode: "all"
behavior: "priced_out"
Wholesale Price Spread Looks Too High#
Symptom: Averaging network.buses_t.marginal_price directly gives an
unrealistic price spread in the wholesale network.
Solution: Use resources/market/{scenario}_wholesale_price.csv. The market
reporting code filters to demand buses and avoids internal DC-link buses that can
retain directional shadow prices.
Data Issues#
FES Data Not Found#
Symptom: Error loading FES data
Solutions:
Check FES year is available:
ls resources/FES/Regenerate FES data:
snakemake resources/FES/FES_2024_data.csv -j 1 -R
DUKES Coordinates Missing#
Symptom: Generators without coordinates
Solutions:
Check for manual coordinate file:
ls data/generators/manual_coordinates.csvRun coordinate geocoding:
python scripts/geocode_missing_coordinates.py
Weather Cutout Missing#
Symptom: “Cutout not found” for renewables year
Solutions:
For years 2010-2024 (automatic Zenodo download):
# Configure year in config/cutouts_config.yaml # Then run cutout workflow snakemake -s Snakefile_cutouts --cores 1
Cutouts will be automatically downloaded from Zenodo (~5-10 minutes per year). No CDS API credentials required for these years!
For other years (requires CDS API credentials):
Register at: https://cds.climate.copernicus.eu/user/register
Set up
~/.cdsapircwith your API keyRun:
snakemake -s Snakefile_cutouts --cores 1
Quick fix - Use an available year:
renewables_year: 2019 # Year with available cutout
Check what’s available:
ls resources/atlite/cutouts/ # Should show: uk-2019.nc, uk-2020.nc, etc.
Note: Zenodo cutouts are automatically verified with MD5 checksums.
Logging Issues#
Empty Log Files#
Symptom: Log files exist but are empty
Cause: Scripts not using snakemake.log[0]
Solution: This was fixed in v0.1. If still occurring:
# In script's main block
log_path = snakemake.log[0] if snakemake.log else "fallback"
logger = setup_logging(log_path)
“Logger Not Defined”#
Symptom: NameError: name 'logger' is not defined
Solution:
from scripts.logging_config import setup_logging
logger = setup_logging("my_script")
Getting Help#
Before Asking#
Check this troubleshooting guide
Search existing GitHub Issues
Check the relevant log file
Information to Include#
When reporting an issue:
Environment:
conda list | grep -E "pypsa|snakemake|pandas" python --version
Command run:
snakemake target.nc -j 4
Full error message (copy from terminal)
Log file contents (from
logs/)Configuration snippet (relevant scenario)
Quick Diagnostic#
Run this to collect system info:
import sys
import pypsa
import pandas
import snakemake
print(f"Python: {sys.version}")
print(f"PyPSA: {pypsa.__version__}")
print(f"Pandas: {pandas.__version__}")
print(f"Snakemake: {snakemake.__version__}")