How to Install PIL/Pillow Using PIP?

In Python, the “PIL” library deals with images. However, it has not been updated and was discontinued in 2011. Nowadays, a newer and more actively maintained version named “Pillow” is used. The Pillow library is a fork of PIL.

Pillow has various functions that can help you work with images. It can open, manipulate, and save image files in formats like BMP, JPEG, PNG, etc. To use PIL/PIllow in Python, we need to install it in the system.

This post will demonstrate the installation process of the PIL/Pillow module in various operating systems:

Installing Pillow on Windows

To install a pillow on windows, you must follow the following steps:

Step 1: Open CMD Terminal

To open the cmd terminal you need to type cmd on the start menu search bar and select the “Run as administrator” option.

Step 2: Install PIL/Pillow Module

After opening the terminal, now type the given below command:

> pip install pillow

The above snippet verified that the “pillow-9.4.0” had been successfully installed.

If you have Python 3, then you can use the following alternative command to install pillow:

> pip3 install pillow

To install Pillow in Anaconda Environment, you can use the below command:

> conda install -c anaconda pillow

To install Pillow/PIL module in Jupyter Notebook, type the following command:

> !pip install pillow
> !pip3 install pillow

Installing Pillow on Linux

To install pillow on Linux you can use the give bellow command:

$ pip install pillow

You can also use the “apt” command for installing Python Pillow on Linux.

$ sudo apt install pillow

To install the “PIL/Pillow” module in Ubuntu 22.04, type the below command in the terminal one after another. The below command is utilized to upgrade the pip:

$ python3 -m pip install --upgrade pip

After upgrading the pip now, you can type the below command to install the “PIL/Pillow” module in ubuntu:

$ python3 -m pip install --upgrade Pillow

The above snippet verified that the “PIllow-9.4.0” had been successfully installed.

Installing Pillow on Mac

To install a pillow on MacOS, type the following command one after the other.

The below command is utilized to upgrade the pip:

pip3 install --upgrade pip

The command below is used to install the pillow module:

pip3 install Pillow

Conclusion

To install PIL/Pillow, the “pip” package manager is used in Windows, Linux, and MacOS. The “pip install pillow” command/code is used to install the pillow module on Windows. The “apt” package manager command is used in Linux to install the pillow package in Python. To avoid errors, we need to upgrade the pip using the upgrade command before installing the Pillow module. This post presented an in-depth guide on installing PIL/Pillow Module in windows, Linux, and macOS.