Can't install Pillow on centos
Categories:
Troubleshooting Pillow Installation on CentOS: A Comprehensive Guide

This article provides a detailed guide to resolve common issues when installing the Pillow library on CentOS, especially with older Python versions like 2.6, covering dependency management and build failures.
Installing Python packages, especially those with C extensions like Pillow (the friendly PIL fork), can be challenging on enterprise Linux distributions such as CentOS, particularly when dealing with older Python versions like 2.6. This guide will walk you through the common pitfalls and provide robust solutions to ensure a successful Pillow installation, focusing on dependency management and proper build environments.
Understanding Common Installation Failures
Pillow relies on several external C libraries for image processing capabilities, including libjpeg
, zlib
, libtiff
, freetype
, and lcms
. If these development headers and libraries are not present on your system, the Pillow installation process will fail during the compilation phase, often with cryptic error messages indicating missing files or functions. Another common issue arises from outdated setuptools
or pip
versions, which might not correctly handle the build process or dependency resolution.
flowchart TD A[Start Pillow Installation] --> B{Check for Python Headers?} B -- No --> C[Install python-devel] B -- Yes --> D{Check for JPEG/Zlib/TIFF/FreeType Dev Libraries?} D -- No --> E[Install libjpeg-devel, zlib-devel, libtiff-devel, freetype-devel, lcms2-devel] D -- Yes --> F{Check setuptools/pip version?} F -- Outdated --> G[Upgrade setuptools/pip] F -- Up-to-date --> H[Attempt Pillow Installation] C --> D E --> F G --> H H -- Success --> I[Pillow Installed] H -- Failure --> J[Review Build Logs for Specific Errors] J -- Resolve --> H
Pillow Installation Troubleshooting Flowchart on CentOS
Prerequisites: Essential System Libraries and Tools
Before attempting to install Pillow, ensure that your CentOS system has all the necessary development packages. These packages provide the header files and static libraries that Pillow's C extensions need to compile against. Without them, the build process will inevitably fail. We'll use yum
to install these dependencies.
sudo yum install -y python-devel
sudo yum install -y libjpeg-devel zlib-devel libtiff-devel freetype-devel lcms2-devel
sudo yum install -y gcc
Installing essential development libraries and compilers on CentOS
python-devel
package provides the necessary header files for Python itself, which are crucial for compiling any Python package with C extensions. gcc
is the GNU C Compiler, essential for building C/C++ components.Upgrading setuptools and pip
Outdated versions of setuptools
and pip
can sometimes lead to installation issues, especially with newer packages or complex build requirements. It's a good practice to ensure these tools are up-to-date before installing Python libraries. For Python 2.6, you might need to use easy_install
first to update pip
.
sudo easy_install pip
sudo pip install --upgrade pip setuptools
Upgrading pip and setuptools for Python 2.6
sudo pip install
. It's often recommended to use virtualenv
to isolate project dependencies and avoid conflicts with system packages. However, for system-wide tools or older environments, direct installation might be necessary.Installing Pillow
Once all prerequisites are met and pip
is updated, you can proceed with installing Pillow. If you encounter issues, the --verbose
flag can provide more detailed output for debugging.
sudo pip install Pillow
Standard Pillow installation command
If the installation still fails, examine the output carefully. Look for specific error messages related to missing files or compilation failures. Sometimes, the error might point to a specific library that was not correctly installed or configured. You can also try installing a specific version of Pillow if the latest version has compatibility issues with your Python 2.6 environment.
sudo pip install Pillow==2.6.0 # Example for a specific version compatible with Python 2.6
sudo pip install Pillow --verbose # For detailed error output
Installing a specific Pillow version or using verbose output for debugging