Why Do I Get an Error Installing Pillow 3.0.0 on Ubuntu? Fixes & Troubleshooting Guide
Pillow, the Python Imaging Library (PIL) fork, is a cornerstone for image processing in Python, powering tasks like image resizing, filtering, and format conversion. However, installing older versions like Pillow 3.0.0 (released in 2015) on modern Ubuntu systems often leads to frustrating errors. This guide demystifies why these errors occur and provides step-by-step fixes to get Pillow 3.0.0 up and running.
Table of Contents#
- Why Errors Occur When Installing Pillow 3.0.0 on Ubuntu
- Step-by-Step Troubleshooting & Fixes
- Conclusion
- References
Why Errors Occur When Installing Pillow 3.0.0 on Ubuntu#
Pillow 3.0.0 is over 8 years old (released in 2015), and Ubuntu systems have evolved significantly since then. Below are the most common causes of installation failures:
1.1 Python Version Compatibility Issues#
Pillow 3.0.0 only supports Python 2.6, 2.7, 3.3, 3.4, and 3.5. Modern Ubuntu systems (e.g., 20.04+, 22.04+) ship with Python 3.8+ by default. If you’re using Python 3.6 or newer, Pillow 3.0.0 will fail to install, often with errors like:
RuntimeError: Python version 2.7 or 3.3+ is required (found 3.9.7).
1.2 Missing System Dependencies#
Pillow relies on low-level image libraries (e.g., libjpeg for JPEG support, zlib for PNG). Ubuntu doesn’t preinstall all of these, and missing ones trigger compilation errors. Common culprits include:
libjpeg-dev: For JPEG image processing.zlib1g-dev: For PNG compression.libpng-dev: For PNG image support.python-dev/python3-dev: For Python header files (required to compile C extensions).
Example error from missing libjpeg-dev:
fatal error: jpeglib.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
1.3 Outdated Tools (Pip, Setuptools)#
Older versions of pip or setuptools may struggle to resolve dependencies or compile Pillow 3.0.0. For example, pip < 9.0 lacks support for modern wheel formats, forcing Pillow to compile from source (which exacerbates dependency issues).
1.4 Conflicts with Existing PIL/Pillow Installations#
If you previously installed PIL (the original, unmaintained library) or a newer Pillow version, leftover files can conflict with Pillow 3.0.0. Errors may include:
ImportError: cannot import name '_imaging' from 'PIL'
1.5 Platform-Specific Compilation Errors#
Ubuntu’s newer compilers (e.g., GCC 9+) may flag deprecated code in Pillow 3.0.0 as errors (not warnings). For example, stricter type-checking can break legacy C extensions in Pillow 3.0.0.
Step-by-Step Troubleshooting & Fixes#
Follow these steps to resolve installation errors for Pillow 3.0.0 on Ubuntu:
2.1 Verify Python Version Compatibility#
First, confirm you’re using a Python version supported by Pillow 3.0.0 (2.6, 2.7, 3.3–3.5).
Check your Python version:
python --version # For Python 2 (if installed)
python3 --version # For Python 3 If using Python 3.6+, you have two options:
- Option 1 (Recommended): Use a compatible Python version via
pyenv(a Python version manager).
Example: Install Python 3.5.9 withpyenv:# Install pyenv dependencies sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \ libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm \ libncursesw5-dev xz-utils tk-dev libxml2-dev libxmlsec1-dev libffi-dev liblzma-dev # Install pyenv curl https://pyenv.run | bash # Add pyenv to PATH (add to ~/.bashrc or ~/.zshrc) echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(pyenv init -)"' >> ~/.bashrc echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc source ~/.bashrc # Install Python 3.5.9 pyenv install 3.5.9 # Set it as the local version for your project pyenv local 3.5.9 - Option 2: Use Ubuntu’s legacy Python packages (not recommended for new projects).
2.2 Install Required System Dependencies#
Pillow 3.0.0 needs system libraries to compile. Install them with:
sudo apt-get update
sudo apt-get install -y \
libjpeg-dev \
zlib1g-dev \
libpng-dev \
libtiff5-dev \
libfreetype6-dev \
python-dev # For Python 2
# OR for Python 3 (use the version matching your Python, e.g., python3.5-dev)
python3.5-dev # If using Python 3.5 Note: Replace python3.5-dev with python3.3-dev or python3.4-dev if using those versions.
2.3 Update Pip and Setuptools#
Ensure pip and setuptools are up-to-date to avoid tooling issues:
# For Python 2
pip install --upgrade pip setuptools
# For Python 3
pip3 install --upgrade pip setuptools Now try installing Pillow 3.0.0 again with:
pip install pillow==3.0.0 # Python 2
# OR
pip3 install pillow==3.0.0 # Python 3 2.4 Uninstall Conflicting PIL/Pillow Versions#
If you see ImportError or "already installed" errors, remove existing PIL/Pillow first:
# Uninstall PIL (if present)
pip uninstall -y PIL
# Uninstall other Pillow versions
pip uninstall -y pillow
# For Python 3
pip3 uninstall -y PIL pillow Then reinstall Pillow 3.0.0 as above.
2.5 Compile Pillow 3.0.0 from Source (If Needed)#
If pip still fails, force compilation from source and explicitly link dependencies. Use --no-binary to bypass prebuilt wheels:
# For Python 3.5 (adjust flags for your Python version)
pip3 install pillow==3.0.0 --no-binary :all: \
--global-option=build_ext \
--global-option="-I/usr/include/freetype2" \
--global-option="-L/usr/lib/x86_64-linux-gnu" The flags -I and -L tell the compiler where to find header files and libraries (adjust paths if your Ubuntu uses different locations).
2.6 Check Error Logs for Clues#
If errors persist, inspect the full installation log. Use pip -v for verbose output:
pip install pillow==3.0.0 -v # Python 2
# OR
pip3 install pillow==3.0.0 -v # Python 3 Look for lines like fatal error: X.h: No such file or directory—this tells you exactly which dependency is missing (e.g., X.h points to libX11-dev for X11 support).
Conclusion#
Installing Pillow 3.0.0 on modern Ubuntu requires addressing Python compatibility, missing system dependencies, and outdated tools. Key steps include:
- Using Python 2.7 or 3.3–3.5.
- Installing libraries like
libjpeg-devandpython3-dev. - Upgrading
pipandsetuptools. - Removing conflicting PIL/Pillow versions.
Note: Pillow 3.0.0 has security vulnerabilities (e.g., CVE-2016-0775). For non-legacy projects, use the latest Pillow version instead.