Try this Jupyter extension

Background image by Free-Photos from Pixabay

By default, when the output of a code cell in a Jupyter notebook gets too long, the content remains in its initial position and you have to manually scroll down to see the latest output. And this can be very annoying.

For example, if you train a Machine Learning model from a Jupyter notebook and you want some info to be printed after each batch or epoch, you would like to have the output automatically scrolling so that you can see the message about the last printed epochs, but instead, nothing happens, you have to scroll down manually.

Below is a for loop that simulates this type of output. This is what usually happens in a Jupyter notebook:

But the good news is that there is a solution to this problem. There is a Jupyter extension named scroll_down that can be used to automatically scroll down through the output.

It doesn’t come with the usual Jupyter installation, so we have to install it separately.

Let’s start by installing this Jupyter extension.


Firstly, we need to install the jupyter_contrib_nbextensions python package. This package will then be used to install the extensions and to activate/deactivate a certain extension.

pip install jupyter_contrib_nbextensions

Then, we need to install the extensions themselves. And what this means is that we basically copy all the javascript and CSS files of all available extensions to the Jupyter data directory and then edit the relevant config files. In Windows, the folder in which these extensions are copied is %APPDATA%\jupyter, in Linux is ~/.local/share/jupyter, and in Mac is ~/Library/Jupyter.

Below is the command that does these things:

jupyter contrib nbextension install --user

After we installed the extensions, we need to enable the scroll_down extension. We do this by using the following command:

jupyter nbextension enable scroll_down/main

Enabling from Jupyter Notebook

This may seem strange, but we need to enable this extension twice. Well, kind of…

After we enabled it from the command line, with the command above, we need to enable it also from a Jupyter Notebook GUI.

So, open a notebook; it can be any notebook.

Now you should be able to see a button with a double down-arrow positioned in on the top bar; something like this:

To activate the extension, click that button and let it into a press-down state, then the output of a code cell will be automatically scrolled down.

Make sure the button is pressed like this:

Now, if we run the same piece of code as earlier in this article, the output of the cell will automatically scroll down so that we can see the latest printed messages, like this:

And that’s it! Now you don’t have to scroll down manually through a cell’s output.

I hope you found this information useful and thanks for reading!

This article is also posted on Medium here. Feel free to have a look!


Passionate about Data Science, AI, Programming & Math

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x