How To Install Pil In Python Using Cmd

In this tutorial, we will guide you through the installation of the Python Imaging Library (PIL) using the command prompt. PIL is a powerful open-source library that adds image-processing capabilities to your Python interpreter. With PIL, you can perform tasks such as reading, writing, and modifying images in various formats.

In 2011, the development of PIL had been discontinued, and a new fork called Pillow was introduced to continue the project. This tutorial will also cover the installation of Pillow, which is considered the modern and maintained version of PIL. Make sure to follow the appropriate steps for the version you want to install on your system.

Step 1: Check Your Python Version

Before installation, it is important to verify which version of Python is installed on your system. Open the command prompt (cmd) and type the following command:

This will output your Python version. Take note of your Python version as the installation process varies depending on whether you are using Python 2 or Python 3.

Step 2: Install pip

To install PIL or Pillow, you’ll first need to have the package installer for Python, pip, installed on your system. If you are using Python 2.7.9 or later, or Python 3.4 or later, pip will already be installed by default. If it is not available, you can install it by following the instructions in the official pip documentation.

Step 3A: Install PIL (Python Imaging Library)

If you prefer to install PIL (not recommended), open the command prompt and enter the following command depending on your Python version:

For Python 2:

For Python 3:

Keep in mind that, although PIL is still available, it is no longer maintained or updated. We strongly recommend using the updated version, Pillow, which is covered in the next step.

Step 3B: Install Pillow (Recommended)

If you want to install Pillow, the maintained and updated version of PIL, open the command prompt and enter the following command depending on your Python version:

For Python 2:

For Python 3:

Once the installation is complete, you can verify that Pillow was successfully installed by running the following Python code snippet:

Output:

You should see the installed Pillow version displayed as output.

Conclusion

In this tutorial, we demonstrated how to install the Python Imaging Library (PIL) and its modern version, Pillow, using the command prompt. With PIL or Pillow, you can now perform powerful image-processing tasks using Python.

Remember, Pillow is an actively maintained and updated version of PIL, so it is recommended to use Pillow for future projects. Happy coding!