Getting started

This page is organized as follow:

In this chapter we present how to install grid2op.



This software uses python (at tested with version >= 3.6).

It is available on pypi (python package index) and can be installed easily (see the next section). It does not depends on non python package. Python requirements are installed with grid2op if you do not have them already.


From source (advanced user)

If you want to develop new grid2op module (for example a new types of Backend, or a new kind of Chronics to read new types of data) this section is made for you.

First, it is recommended (but optionnal) to make a virtual environment:

pip install -U virtualenv

The second step is to clone the Grid2Op package (git is required):

git clone
cd Grid2Op
python3 -m virtualenv venv_grid2op

This should create a folder Grid2Op with the current sources.

Then the installation script of Grid2Op can be run to install the current simulator (including the Python libraries dependencies):

cd Grid2Op/
source venv_grid2op/bin/activate
pip install -e .

After this, this simulator is available under the name grid2op (from a python console)

import grid2op

Start Using grid2op

To get started into the grid2op ecosystem, we made a set of notebooks that are available, without any installation thanks to Binder . Feel free to visit the “getting_started” page for more information and a detailed tour about the issue that grid2op tries to address.

The most basic code, for those familiar with openAI gym (a well-known framework in reinforcement learning) is:

import grid2op
# create an environment
env_name = "l2rpn_case14_sandbox"  # for example, other environments might be usable
env = grid2op.make(env_name)

# create an agent
from grid2op.Agent import RandomAgent
my_agent = RandomAgent(env.action_space)

# proceed as you would any open ai gym loop
nb_episode = 10
for _ in range(nb_episode):
    # you perform in this case 10 different episodes
    obs = env.reset()
    reward = env.reward_range[0]
    done = False
    while not done:
        # here you loop on the time steps: at each step your agent receive an observation
        # takes an action
        # and the environment computes the next observation that will be used at the next step.
        act = my_agent.act(obs, reward, done)
        obs, reward, done, info = env.step(act)


Grid2Op environments implements the interface of defined by openAI gym environment, but they don’t inherit from them. You can use the Grid2Op environment as you would any Gym environment but they are not strictly speaking gym environment.

To make the use of grid2op alongside grid2op environment easier, we developed a module described in Compatibility with gymnasium / gym.