Python Image Library Setup



First make sure that Python is installed on platform by issuing the command

C:\>python --version

Here we are going to demonstrate the pillow installation as PIL is an outdated version and not in active state.

Pillow library has currently two versions.
Pillow 2.8.1
Pillow 1.7.8

Pillow 1.7.8 has to be used if you are using the Python 2.6 or lower than that.
Pillow 2.8.1 is supposed to be installed if you are using the Python 2.7 or later versions.

Note: PIL and Pillow currently cannot co-exist in the same environment. If you want to use Pillow, please remove PIL first.

Check whether the PIL library exists or not
If the module exist it returns nothing and if any module doesnt exist it returns error message that module doesnt exist.

python c import PIL

Windows Installation

Here are the simple steps for installing Pillow 2.8.1 in windows.
Open the web server and go to https://pypi.python.org/pypi/Pillow/2.8.1
You will be able to find all the downloadable files for various Python versions and for different python versions.
Select any executable file based on your python version and windows architecture.
Save the selected executable file to your local machine
Run the downloaded file and now the install wizard appears in front of you.
Accept all the default settings but make sure that the Installation is done in the Python lib directory

Also there is another way of installation where you can download the library source package and follow the below instructions.

Open the web server and go to https://pypi.python.org/pypi/Pillow/2.8.1
Scroll down the page where somewhere at the end of the page you can find the file in zip format with name Pillow-2.8.1.zip.
Download the zipped file to your local system folder.
Unzip the file and navigate into it.
python setup.py install

UNIX & Linux Installation

For most of the linux flavors include Pillow with their latest distributions. So theres nothing to do. Instead of starting the below installation process directly check the pillow library has been installed or not.

Below is the generalized process of installing PIL or Pillow packages in any flavor of Linux.

Open the terminal
sudo apt-get install python-pip
In python 3.x sudo apt-get install python3-pip
sudo pip install Pillow
In Python3.x sudo pip3 install Pillow

There is other way of installing python from the source code.
Download the zip file Pillow-2.8.1.zip from https://pypi.python.org/pypi/Pillow/2.8.1
unzip Pillow-2.8.1.zip
cd Pillow-2.8.1
python setup.py install

Sometimes the installation may fail if the dependencies are not installed.Install the dependencies first and then follow any of the above steps to install Pillow

$sudo apt-get install libjpeg-dev libfreetype6-dev zlib1g-dev
Advertisements