Python Forum

Full Version: Shoud we use PIL or Pillow?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Which of the two should we use and why?

My Kubuntu 22.04 OS comes with python3-pil installed. Can I install python3-pillow and use both of them?
You only use Pillow.
Original maintainers of the PIL stopped working on it a long time⏲ ago.
Pillow is repackaged(drop-in replacement) and much updated version of original PIL
Still use PIl in import as in original just to keep backward compatible.
from PIL import Image

img = Image.open('image.png').convert('L')
img.save('greyscale.png')
Gribouillis Wrote:My Kubuntu 22.04 OS comes with python3-pil installed. Can I install python3-pillow and use both of them?
I would not use OS install at all,they may not be updated.
Just use pip.
pip install Pillow --upgrade
(Aug-12-2022, 02:08 PM)snippsat Wrote: [ -> ]Just use pip.
I did that and it seems to work well
Output:
λ python -m pip install Pillow --upgrade Defaulting to user installation because normal site-packages is not writeable Requirement already satisfied: Pillow in /usr/lib/python3/dist-packages (9.0.1) Collecting Pillow Downloading Pillow-9.2.0-cp310-cp310-manylinux_2_28_x86_64.whl (3.2 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.2/3.2 MB 8.8 MB/s eta 0:00:00 Installing collected packages: Pillow Successfully installed Pillow-9.2.0 λ python Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import PIL >>> PIL <module 'PIL' from '/home/eric/.local/lib/python3.10/site-packages/PIL/__init__.py'> >>> λ python -m PIL -------------------------------------------------------------------- Pillow 9.2.0 Python 3.10.4 (main, Jun 29 2022, 12:14:53) [GCC 11.2.0] ...
(Aug-12-2022, 02:45 PM)Gribouillis Wrote: [ -> ]I did that and it seems to work well
Works fine🎈