How To Install Pillow On Windows, Linux & Mac

Pillow can run across platforms, such as Windows, Linux, macOS, etc. The latest version is Pillow 8.4.0, which supports Python 3.6 and above (recommended). This article will tell you what is pillow, and how to install the python pillow module on Windows, Linux & macOS.

1. What Is Pillow?

  1. PIL (Python Imaging Library) is the third-party image processing library of Python. It is highly praised because of its rich functions and simple API.
  2. Since 2011, due to the slow update of the PIL library and only supporting Python version 2.7, it obviously can not meet the use requirements of Python version 3. So a group of Python community volunteers developed an image processing library supporting Python 3 based on the PIL library, which is Pillow.
  3. Pillow is not only a “replica” of the PIL library but also adds many new features to the PIL library. Till now, the pillow has become a more active image processing library than PIL.
  4. Now Pillow is the basic image processing library in Python that is used for basic images processing, such as cropping, resizing, and color processing.

2. Pillow vs OpenCV vs Scikit-image.

  1. In addition to the PIL and Pillow libraries, python also provides some other image processing libraries such as OpenCV, Scikit-image.
  2. OpenCV is actually a C++ image processing library, but it provides a Python interface.
  3. Scikit-image is an image processing software package based on Scipy that processes images in the form of arrays.
  4. Compared with Pillow, OpenCV and Scikit-image have richer functions, so they are more complex to use. They are mainly used in machine vision, image analysis, and other fields, such as the well-known “face recognition” application.

3. Pillow Package Features.

  1. Pillow supports a wide range of image formats, such as “JPEG”, “PNG”, “BMP”, “GIF”, “PPM”, “TIFF” and more. It also supports conversion between image formats.
  2. Pillow provides rich image processing capabilities that can be summarized in two areas, they are image archive and image processing.
  3. Image archiving includes creating thumbnails, generating preview images, image batch processing, etc.
  4. Image processing includes adjusting image size, cutting images, pixel processing, adding filters, image color processing, and so on.
  5. The Pillow library can be used with the Python GUI (graphical user interface) tool Tkinter.
  6. The Pillow library can also perform more complex image processing operations, such as adding watermarks to images and compositing animated gifs.

4. How To Install Python Pillow Library.

  1. Pillow installation is very simple and convenient, there are three ways to install the Pillow, they are 1) Install using PIP package manager, 2) Install using Anaconda, 3) Install using the binary package files.
  2. Note that the PIL library and Pillow library are not allowed to coexist in the same environment. If you have installed the PIL library before, please uninstall it and then install Pillow.

4.1 Install Pillow Using Anaconda.

  1. Anaconda is an open-source distribution of Python, it is a popular scientific computing platform, supporting Windows, Linux, and macOS systems ( you can refer to How To Install Anaconda On Linux, Windows, macOS Correctly). So we recommend you use it.
  2. Open the Anaconda navigator window, then click the Environments menu item on the Anaconda navigator left panel.
  3. Then select the virtual environment item that you need on the window’s middle side virtual environments list.
  4. On the window right side, select All from the drop-down list, then input the keyword pillow in the search box.
  5. If your anaconda has downloaded the pillow module, it will show the pillow module below the search box.
  6. You can check the checkbox before the pillow module and then click the Apply button to install it.
  7. You can read the article How To Install/Uninstall Python Packages In Anaconda Virtual Environment Successfully to learn more.

4.2 Install Pillow Using PIP Package Manager.

  1. Installing Pillow through the PPIP is the simplest, lightweight way to install it, and it works on any platform.
  2. Open a terminal and run the command pip install pillow in it to install the python pillow module.
  3. Then run the command pip show pillow to verify that pillow has been installed successfully.
    $ pip show pillow
    Name: Pillow
    Version: 8.1.0
    Summary: Python Imaging Library (Fork)
    Home-page: https://python-pillow.org
    Author: Alex Clark (PIL Fork Author)
    Author-email: [email protected]
    License: HPND
    Location: /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages
    Requires: 
    Required-by: vaex-viz, streamlit, matplotlib, ipyvolume

4.3 Install Pillow Using The Binary Package Files.

  1. Go to the pillow package files download page to download the pillow binary files that match your OS and version.
  2. Then open a terminal and run the below commands to install the pillow module with the above binary files.
  3. For Windows, you can run the command py -m pip install ./downloads/Pillow-8.4.0.tar.gz.
  4. For Linux & macOS, you can run the comand python3 -m pip install ./downloads/Pillow-8.4.0.tar.gz.
  5. You can read the Install a particular python module through the local source archive file to learn more.

5. How To Use Pillow In Python Source Code.

  1. Open a terminal and run the command python in it to open the python interpreter console.
  2. Then input the python source code from PIL import Image in the python console and press the enter key.
  3. If there is no error prompts, then it means the python pillow module has been installed successfully.
    $ python
    Python 3.7.3 (v3.7.3:ef4ec6ed12, Mar 25 2019, 16:52:21) 
    [Clang 6.0 (clang-600.0.57)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    >>> from PIL import Image # Import the Image class, which is an important class in pillow for Image processing.
    

Leave a Comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.