When working in Jupyter Notebook, it can be common for a code cell to take a long time to run, especially for tasks like machine learning model training or hyperparameter optimization — which is where Jupyter Notebook notifications can be helpful.
Jupyternotify is a Python package and Jupyter extension that sends a browser push notification when a code cell execution process has finished in a Jupyter notebook, so you can focus on other tasks in the mean time and still know when code is done running.
What Is Jupyternotify for Jupyter Notebook?
Jupyternotify is a Jupyter Notebook extension that notifies the user once a long-running cell has finished executing through a browser notification. Jupyternotify is supported by Google Chrome and Firefox.
In this article, I’ll show you how to enable notifications in Jupyter Notebook and Jupyter Lab using jupyternotify.
What Is Jupyternotify?
Jupyternotify is a Jupyter Notebook extension that notifies the user once a long-running cell has finished executing through a browser notification. It is supported by both Google Chrome and Firefox. However, if you face any issues regarding the installation, you can follow these detailed instructions to get things up and running.
Let’s now see how we can install the package and use it.
How to Install Jupyternotify
You can install the stable version of jupyternotify
from PyPI by using pip directly in your Jupyter notebook:
pip install jupyternotify
Alternatively, if you need the latest development features, you can install it from the source code on GitHub. Note that this method may be less stable and requires additional steps:
git clone [email protected]:ShopRunner/jupyter-notify.git
cd jupyter-notify/
virtualenv venv
source venv/bin/activate
pip install -r requirements.txt
jupyter notebook
How to Turn On Notifications in Jupyter Notebook With Jupyternotify
To enable the jupyternotify
extension in Jupyter Notebook, you must first load the magic command by running:
%load_ext jupyternotify
This command prepares your notebook to use the extension’s features, like the %%notify
magic.
When you run this cell for the first time, your browser will ask you to allow notifications in your notebook; click “Yes.”
Now we’re all set.
Jupyternotify Example
For a simple demonstration, we’ll use Python’s time
module.
First, import the module, and then use the time.sleep()
function to pause the execution. The %%notify
magic command is a cell magic, which means it’s placed at the very top of a cell to apply to all the code within it.
%%notify
import time
time.sleep(10)
print('Finished!')
On executing the above cell, you’ll get the following notification in your browser:

In many browsers, clicking the notification body will take you directly to the browser window and tab where your notebook is running. However, this behavior can sometimes vary depending on your browser and operating system settings.
How to Turn On Notifications in Jupyter Lab With Jupyternotify
While there is currently no official jupyternotify
support for Jupyter Lab, I found a workaround. Apparently, a user has submitted a pull request with the solution, but it hasn’t been merged yet. However, the solution works seamlessly.

Paste the following in a Jupyter Lab cell followed by the code you wish to run:
!pip uninstall jupyternotify -y
!pip install git+https://github.com/cphyc/jupyter-notify.git
%reload_ext jupyternotify
We’ll now use the same code as above to check if the notifications are enabled or not.
%%notify
import time
time.sleep(5)
How to Customize Jupyternotify Browser Notification Message
If you wish to have a fancier notification message, you can easily tweak the code to do so.
%%notify -m "Congrats.The process has finished"
import time
time.sleep(3)

Many other options are available. For instance, you can fire a notification in the middle of a cell or automatically trigger the notification after a certain time. I highly encourage you to check out the package’s GitHub repository for detailed information.
A feature as trivial as a notification can be beneficial, especially when you regularly work with processes that take a lot of time to execute. It’s pretty handy to be able to navigate to another tab or even a desktop and still get notified when a running process finishes. Sometimes, small add-ons like Jupyter Notify can really help to increase your productivity and smooth out your workflow.
Frequently Asked Questions
What is jupyternotify?
jupyternotify
is a Jupyter extension that sends a browser notification once a code cell has completed its execution. This is particularly useful for tasks like machine learning model training or complex data computations that can take a significant amount of time.
How do I install the jupyternotify extension?
You can install the jupyternotify extension by using pip
directly in a Jupyter notebook:
pip install jupyternotify
How do I turn on notifications for a Jupyter notebook?
After installing the jupyternotify
extension, load it by running the following command in a code cell at the beginning of your Jupyter notebook:
%load_ext jupyternotify
Afterward, you can use the %%notify
magic command at the top of any cell to get a notification when its execution is complete.