IOPub data rate exceeded in Jupyter Notebook [Solved]

avatar
Borislav Hadzhiev

Last updated: Apr 5, 2024
3 min

banner

# IOPub data rate exceeded in Jupyter Notebook [Solved]

The Jupyter Notebook error "IOPub data rate exceeded" occurs when the default IOPub rate has been exceeded, commonly when trying to render images.

To solve the error, use the Jupyter Notebook CLI to increase your IOPub data rate limit.

The error is commonly caused when trying to render an image.

main.py
from IPython.display import Image, display img = Image(filename='house.png') # ⛔️ IOPub data rate exceeded. # The notebook server will temporarily stop sending output to the client in order to avoid crashing it. display(img)

To solve the error, increase your IOPub data rate limit using the Jupyter Notebook CLI.

Open your terminal and run the following command.

shell
jupyter notebook --NotebookApp.iopub_data_rate_limit=1.0e10

update jupyter notebook iopub data rate limit

You can also run the following command directly in a Jupyter Notebook cell.

shell
!jupyter notebook --NotebookApp.iopub_data_rate_limit=1.0e10

increase iopub rate in jupyter notebook

The command will increase the IOPub data rate limit.

Try to rerun the code that displays your image in Jupyter Notebook after issuing the command.

main.py
from IPython.display import Image, display img = Image(filename='house.png') display(img)

display image successfully

# Increasing the IOPub data rate in a configuration file

If the error persists, you can try to increase the IOPub data rate limit in your jupyter_notebook_config.py file.

  1. Generate the file by running the following command.
shell
jupyter notebook --generate-config

generate jupyter notebook config file

Notice that your terminal tells you where the file is located.

  • Writing default config to: /path/to/jupyter_notebook_config.py.

On macOS and Linux, the file is located at ~/.jupyter/jupyter_notebook_config.py.

  1. Open the jupyter_notebook_config.py file with a text editor.

  2. Press Ctrl + F (or Cmd + F) and search for c.NotebookApp.iopub_data_rate_limit.

The line will look similar to the following and will be around line 340.

jupyter_notebook_config.py
# c.NotebookApp.iopub_data_rate_limit = 1000000

search for iopub data rate limit line

  1. Uncomment the line and increase the value for the IOPub data rate limit.
jupyter_notebook_config.py
c.NotebookApp.iopub_data_rate_limit = 1000000000

uncomment line and increase iopub data rate

# Try to upgrade Jupyter if the error persists

If the error persists, try to upgrade jupyter.

Open your terminal and run the following command.

shell
pip install jupyter --upgrade # or with pip3 pip3 install jupyter --upgrade

You can also upgrade jupyter using conda.

shell
conda install -c anaconda jupyter conda update jupyter

The issue should be resolved after jupyter version 5.2.2.

# Try to remove unnecessary print() statements

The error is also caused when you have many print() statements and exceed the IOPub data rate.

Try to remove unnecessary print() statements, e.g. ones in a for loop or while loop.

I've also written an article on how to show a PIL image in Jupyter Notebook.

# Additional Resources

You can learn more about the related topics by checking out the following tutorials:

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.