jupyter notebook – Visual Studio Code hangs with reconnecting to kernel when using PIL.Image

Version: 1.76.1 (Universal)

Pillow: 9.4.0 (py310h07496d3_2 conda-forge)

import PIL
from pathlib import Path

img_name = Path.home()/'tmp"https://stackoverflow.com/"testing.jpg'

PIL.Image.open(img_name)

I ran the above code in a Jupyter notebook in Visual Studio Code, and it immediately provoked “Reconnecting to the kernel …”

just wonder if anyone seen this. Note that if I tried the above with just the “plain” Jupyter notebook, it is displaying the jpeg correctly. Also the following code has no error in plain good old Jupyter:

import PIL
PIL.Image

But generated:

AttributeError: module 'PIL' has no attribute 'Image'

in VS Code. Both of them are pointing to the same kernel. I suspect this may have contributing to kernel disconnect in VS Code (where the reconnect is an effective hangs since it may have crashed).

Read more here: Source link