Last updated: Apr 5, 2024
Reading time·3 min
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.
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.
jupyter notebook --NotebookApp.iopub_data_rate_limit=1.0e10
You can also run the following command directly in a Jupyter Notebook cell.
!jupyter notebook --NotebookApp.iopub_data_rate_limit=1.0e10
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.
from IPython.display import Image, display img = Image(filename='house.png') display(img)
If the error persists, you can try to increase the IOPub data rate limit in your
jupyter_notebook_config.py
file.
jupyter notebook --generate-config
Notice that your terminal tells you where the file is located.
/path/to/jupyter_notebook_config.py
.On macOS and Linux, the file is located at
~/.jupyter/jupyter_notebook_config.py
.
Open the jupyter_notebook_config.py
file with a text editor.
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.
# c.NotebookApp.iopub_data_rate_limit = 1000000
c.NotebookApp.iopub_data_rate_limit = 1000000000
If the error persists, try to upgrade jupyter
.
Open your terminal and run the following command.
pip install jupyter --upgrade # or with pip3 pip3 install jupyter --upgrade
You can also upgrade jupyter
using conda
.
conda install -c anaconda jupyter conda update jupyter
The issue should be resolved after jupyter version 5.2.2.
print()
statementsThe 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.
You can learn more about the related topics by checking out the following tutorials: