Skip to content

Bug: TypeError when using source: build for cutout (str / str path division) #2156

Description

@18blasim

Version Checks (indicate both or one)

  • I have confirmed this bug exists on the lastest release of PyPSA-Eur.

  • I have confirmed this bug exists on the current master branch of PyPSA-Eur.

Issue Description

Bug Description

When setting data.cutout.source: build in config.yaml, Snakemake throws a TypeError:

unsupported operand type(s) for /: 'str' and 'str'

Location

rules/build_electricity.smk, line 202

Cause

dataset_version() returns folder as a string (via .as_posix()),
but the code uses the / operator which requires a Path object:

cutout=CUTOUT_DATASET["folder"] / "{cutout}.nc" # ← Bug

In retrieve.smk the same issue is correctly handled with +:

CUTOUT_DATASET["folder"] + "/{cutout}.nc" # ← Correct

Fix

Change line 202 in rules/build_electricity.smk from:
cutout=CUTOUT_DATASET["folder"] / "{cutout}.nc"
to:
cutout=CUTOUT_DATASET["folder"] + "/{cutout}.nc"

Context

This only occurs when using historical weather years not available
on data.pypsa.org (e.g. 1965), which requires source: build.

Version

v2026.02.0

Reproducible Example

1. Set in config.yaml:
   data:
     cutout:
       source: build
       version: latest

2. Run:
   snakemake --cores 4 data/cutout/build/unknown/europe-1965-era5.nc

3. Error occurs immediately before any download starts

Expected Behavior

Snakemake should successfully create the build_cutout rule and
start downloading ERA5 data. The output path should be correctly
constructed as a string, consistent with how retrieve.smk handles
the same variable using + instead of /.

Installed Versions

Details PyPSA-Eur: v2026.02.0 OS: Ubuntu (Uni Server) / macOS (lokal) Python: 3.13

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Fields

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions