I am following the tutorial – https://learn.microsoft.com/en-gb/azure/ai-services/openai/how-to/assistant#supported-file-types
I created a notebook
in Fabric
.
I downloaded the packages using the following commands in a cell
%pip install openai
%pip install openai --upgrade
%pip install pillow
In the last step, when I run the code to open the sinewave.png
file,
from PIL import Image
# Display the image in the default image viewer
image = Image.open("sinewave.png")
image.show()
I get the following error:
---------------------------------------------------------------------------
KeyError Traceback (most recent call last)
File ~/cluster-env/trident_env/lib/python3.10/site-packages/PIL/JpegImagePlugin.py:639, in _save(im, fp, filename)
638 try:
--> 639 rawmode = RAWMODE[im.mode]
640 except KeyError as e:
KeyError: 'RGBA'
The above exception was the direct cause of the following exception:
OSError Traceback (most recent call last)
File ~/cluster-env/trident_env/lib/python3.10/site-packages/PIL/Image.py:643, in Image._repr_image(self, image_format, **kwargs)
642 try:
--> 643 self.save(b, image_format, **kwargs)
644 except Exception as e:
File ~/cluster-env/trident_env/lib/python3.10/site-packages/PIL/Image.py:2413, in Image.save(self, fp, format, **params)
2412 try:
-> 2413 save_handler(self, fp, filename)
2414 except Exception:
File ~/cluster-env/trident_env/lib/python3.10/site-packages/PIL/JpegImagePlugin.py:642, in _save(im, fp, filename)
641 msg = f"cannot write mode {im.mode} as JPEG"
--> 642 raise OSError(msg) from e
644 info = im.encoderinfo
OSError: cannot write mode RGBA as JPEG
The above exception was the direct cause of the following exception:
ValueError Traceback (most recent call last)
File ~/cluster-env/trident_env/lib/python3.10/site-packages/IPython/core/formatters.py:344, in BaseFormatter.__call__(self, obj)
342 method = get_real_method(obj, self.print_method)
343 if method is not None:
--> 344 return method()
345 return None
346 else:
File ~/cluster-env/trident_env/lib/python3.10/site-packages/PIL/Image.py:661, in Image._repr_jpeg_(self)
656 def _repr_jpeg_(self):
657 """iPython display hook support for JPEG format.
658
659 :returns: JPEG version of the image as bytes
660 """
--> 661 return self._repr_image("JPEG")
File ~/cluster-env/trident_env/lib/python3.10/site-packages/PIL/Image.py:646, in Image._repr_image(self, image_format, **kwargs)
644 except Exception as e:
645 msg = f"Could not save to {image_format} for display"
--> 646 raise ValueError(msg) from e
647 return b.getvalue()
ValueError: Could not save to JPEG for display