
This package provides a set of tools for interaction with the Energy Transition Model’s API.
Learn more about the Energy Transition Model here.
The package is designed to be a modular tool that advanced users can incorporate into their scenario workflows.
More documentation is available via the docs.
Installation
Note: If you are not familiar working with python packages, please refer to the quick start guide first.
Install pyetm from PyPI:
pip install pyetm
Requirements: Python 3.12 or later
Check your Python version:
python3 --version
If you need to install Python:
Quick Start
1. Create a Virtual Environment
We recommend using a virtual environment to keep your project dependencies isolated:
# Create a new virtual environment
python3 -m venv .venv
# Activate it
# On macOS/Linux:
source .venv/bin/activate
# On Windows (PowerShell):
.venv\Scripts\Activate.ps1
# On Windows (Command Prompt):
.venv\Scripts\activate.bat
More details on how python virtual environments work can be found here
2. Install pyetm
With your virtual environment activated:
pip install pyetm
Note: New versions of pyetm are consistently released. Check here for the latest release
An example of how to install a specific release:
pip install pyetm==2.0.0
3. Initialize Your Project
Run the interactive setup command:
pyetm init
This will:
- Ask which environment you want to use (production, beta, or local)
- Create a
.env configuration file
- Copy an input template Excel file to
excel/input.xlsx
After initialization, you’ll need to manually add your API token to the .env file:
- Open
.env in your text editor
- Find the commented
# ETM_API_TOKEN= line
- Uncomment it by removing the
#
- Paste your full token after the
= sign (get your token here)
- Save the file
Note: API tokens are very long (1000+ characters). Make sure you paste the entire token.
Command options:
--environment: Target environment (pro, beta, or local)
--force: Overwrite existing files without prompting
Example:
pyetm init --environment pro
4. Run Scenarios from Excel
The easiest way to work with scenarios is using Excel files:
# Edit excel/input.xlsx with your scenario data, then run:
pyetm run excel/input.xlsx
This will load your scenarios, update them on ETM, and export results to excel/input_results.xlsx.
Command options:
--output PATH or -o PATH: Custom output file location
--log-level: Logging verbosity
Example:
# Custom output location
pyetm run excel/input.xlsx --output results/my_results.xlsx
# Read-only mode (fetch data without updating)
pyetm run excel/input.xlsx --no-update
For more detailed ‘pyetm run’ workflow instructions, see the Quick Start Guide in the docs.
Configuration
The pyetm init command creates a .env file with your settings. You can also configure manually:
Configuration
Create a .env file in your project directory, or run pyetm init:
# Your ETM API token (optional for public scenarios)
ETM_API_TOKEN=etm_your_token_here
- Without a token you can read public scenarios.
- With a token you can also create, change and list your scenarios, and read private ones.
- Get your token on your tokens page.
pyetm 2.1 is tested on the latest Version of the ETM. For 2025-01, use
pyetm 2.0.x. See the
compatibility table.
ETM_ENVIRONMENT=beta switches to the beta ETM, and the
configuration page lists the
other settings.
For examples and tutorials, visit our documentation.
Temporary File Storage
The package stores temporary files (cached curves and custom data) in your system’s temp directory:
- macOS/Linux:
/tmp/pyetm/
- Windows:
%TEMP%\pyetm\
Contributing
Interested in contributing to pyetm development? See our Contributing Guide for details on:
- Setting up the development environment with Poetry
- Running tests
- Code style guidelines
- Submitting pull requests
Getting Help
评论