You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I try to display a large-ish image (800x800 JPEG) using the Pillow Python library in Jupyter Notebook before displaying any smaller images in the notebook, the notebook hangs. In the terminal, I see this error message:
[E 11:01:18.952 NotebookApp] Uncaught exception, closing connection.
Traceback (most recent call last):
File "/Users/kerrick/Library/Python/3.11/lib/python/site-packages/tornado/iostream.py", line 702, in _handle_events
self._handle_write()
File "/Users/kerrick/Library/Python/3.11/lib/python/site-packages/tornado/iostream.py", line 976, in _handle_write
self._write_buffer.advance(num_bytes)
File "/Users/kerrick/Library/Python/3.11/lib/python/site-packages/tornado/iostream.py", line 182, in advance
assert 0 < size <= self._size
^^^^^^^^^^^^^^^^^^^^^^
AssertionError
Exception in callback None()
handle: <Handle cancelled>
Traceback (most recent call last):
File "/opt/homebrew/Cellar/[email protected]/3.11.4/Frameworks/Python.framework/Versions/3.11/lib/python3.11/asyncio/events.py", line 80, in _run
self._context.run(self._callback, *self._args)
File "/Users/kerrick/Library/Python/3.11/lib/python/site-packages/tornado/platform/asyncio.py", line 206, in _handle_events
handler_func(fileobj, events)
File "/Users/kerrick/Library/Python/3.11/lib/python/site-packages/tornado/iostream.py", line 702, in _handle_events
self._handle_write()
File "/Users/kerrick/Library/Python/3.11/lib/python/site-packages/tornado/iostream.py", line 976, in _handle_write
self._write_buffer.advance(num_bytes)
File "/Users/kerrick/Library/Python/3.11/lib/python/site-packages/tornado/iostream.py", line 182, in advance
assert 0 < size <= self._size
^^^^^^^^^^^^^^^^^^^^^^
AssertionError
This doesn't always happen consistently. Sometimes the image displays successfully the first time but then I get the crash when I re-run the cell. Other times it displays halfway and cuts off in the middle.
A 600x600 rescale of the same image does not crash the notebook. Also, interestingly, if I display the 600x600 image first and then display the 800x800 image in a later cell, it does not crash.
After this happens the notebook is unresponsive and I can't seem to restart the notebook kernel from the UI; the only recourse is to Ctrl+C the python3 -m jupyter notebook process from the terminal.
To reproduce
Download crash_800x800.jpg and no_crash_600x600.jpg from this Google Drive folder. (Try clicking "Download all" if the normal "Download" link doesn't work; Google seems to have a bug).
Install the Pillow Python library.
Run this code in a notebook. Maybe re-run the cell a couple times:
from PIL import Image
Image.open('crash_800x800.jpg')
Expected behavior
The image displays.
Actual behavior
I get a crash with the above-mentioned error message.
Version information
OS: macOS 13.3.1 (a) (22E772610a) on MacBook Air M2
Jupyter Version: 6.5.4-2c95aa495
Jupyter Python version: Python 3.11.4 (main, Jun 7 2023, 00:34:59) [Clang 14.0.3 (clang-1403.0.22.14.1)]
Jupyter Kernel:
Hi @kerrickstaley thank you for submitting this issue. This is a known bug that has been reported in #6721. Closing this issue as a duplicate of that one.
Summary
When I try to display a large-ish image (800x800 JPEG) using the
Pillow
Python library in Jupyter Notebook before displaying any smaller images in the notebook, the notebook hangs. In the terminal, I see this error message:This doesn't always happen consistently. Sometimes the image displays successfully the first time but then I get the crash when I re-run the cell. Other times it displays halfway and cuts off in the middle.
A 600x600 rescale of the same image does not crash the notebook. Also, interestingly, if I display the 600x600 image first and then display the 800x800 image in a later cell, it does not crash.
After this happens the notebook is unresponsive and I can't seem to restart the notebook kernel from the UI; the only recourse is to Ctrl+C the
python3 -m jupyter notebook
process from the terminal.To reproduce
crash_800x800.jpg
andno_crash_600x600.jpg
from this Google Drive folder. (Try clicking "Download all" if the normal "Download" link doesn't work; Google seems to have a bug).Expected behavior
The image displays.
Actual behavior
I get a crash with the above-mentioned error message.
Version information
OS: macOS 13.3.1 (a) (22E772610a) on MacBook Air M2
Jupyter Version: 6.5.4-2c95aa495
Jupyter Python version: Python 3.11.4 (main, Jun 7 2023, 00:34:59) [Clang 14.0.3 (clang-1403.0.22.14.1)]
Jupyter Kernel:
Browser: Chrome 112.0.5615.137 (Official Build) (arm64)
Notes:
If you instead use
no_crash_600x600.jpg
, the crash will not trigger.Also, if you run these two cells in order:
then you can re-run the second cell repeatedly and it will not crash.
The text was updated successfully, but these errors were encountered: