I’ve just release a new Jupyter Lab extension called autoplay, it runs all the cells of a notebook and hides its code when opening it. In this post I will explain how to install and use it.
Installation
This extension is for Jupyter Lab 2. You can install it running jupyter labextension install jupyterlab-autoplay
.
How to use
Here is a short video of how the extension works:
The extension runs automatically when opening a notebook. To configure a notebook:
- Open a create a new notebook
- Setup the notebook for the extension, use the Jupyter Lab command
Set notebook autorun config

A dialog will open and ask you what action should be performed when opening the notebook. Check both options and confirm.

- This will edit the notebook’s metadata so you will need to save it to store the configuration.
- You can now close the notebook and re-open it to see it being run automatically.
Work with a configured notebook
If you need to edit a notebook that has ran, you can show all the hidden cells by clicking on Show code cells
. This won’t affect the notebook settings so no need to go through the configuration again. You can then edit the code, add new cells, etc.
Warnings
Be careful if you’re using this extension, malicious code could be ran and hidden automatically, so make sure you know that your users are not going to open any dodgy notebook…
Links
- Github repository: https://github.com/remborg/autoplay
- NPM package: https://www.npmjs.com/package/jupyterlab-autoplay
4 replies on “How to run all the cells of a Jupyter Lab notebook when opening it”
Would like to discuss building a few widgets for our internal needs (if you are interested)
Thanks for getting in touch.
I’ve been building extension for nearly 2 years now, I will be able to help 🙂
I have sent you an email so we can have a chat about your projects.
I tried to use the above extension programmatically but metadata is not having an autoplay key so getting key error for the same. Where we need to put autoplay related key values
“autoplay”: {
“autoRun”: true,
“hideCodeCells”: true
}
Hi, I’m not sure if I understand what you mean. You need to put the “autoplay” object in the notebook’s metadata, at root level.
Are you getting an error? Could you share it?