Skip to content

How to Resolve "ERROR: Could not find a version that satisfies the requirement PIL"

Fix the 'No matching distribution found for PIL' error by installing Pillow, i.e. the modern, actively maintained fork that replaces the outdated PIL library.

The ERROR: Could not find a version that satisfies the requirement PIL ... ERROR: No matching distribution found for PIL is a common error when trying to pip install PIL. This occurs because PIL (Python Imaging Library) is an older, unmaintained library. The currently active and recommended fork is Pillow.

This guide shows you how to resolve this error by installing Pillow.

Understanding the Error: PIL vs. Pillow

  • PIL (Python Imaging Library): The original library for image processing in Python. It is no longer actively maintained and does not support recent Python versions or have readily available distributions on PyPI for modern systems.
  • Pillow: A modern, actively maintained fork of PIL. It provides the same core functionality as PIL (and much more) and is designed to be a drop-in replacement.

When you run pip install PIL, pip searches the Python Package Index (PyPI) for a package named PIL. Since the original PIL is not actively published there for modern Python, pip can not find a suitable version, resulting in the "Could not find a version..." error.

The correct way to get PIL-like functionality is to install the Pillow package.

Uninstalling Old PIL (Important)

Before installing Pillow, it's crucial to uninstall any old PIL installations to prevent conflicts:

pip uninstall PIL
pip uninstall Pillow # Also uninstall Pillow if a previous attempt failed partially

pip3 uninstall PIL
pip3 uninstall Pillow
  • Repeat the uninstall commands until they confirm that the package is not found.

Installation Commands

Once any old versions are removed, install Pillow:


pip install Pillow

pip3 install Pillow

python -m pip install Pillow
python3 -m pip install Pillow

conda install -c anaconda pillow # Often preferred within Conda

Troubleshooting Installation Issues

If pip install Pillow still fails, try these steps:

Upgrade pip

An outdated pip might cause issues. Upgrade it:

python -m pip install --upgrade pip

Check Python Version Compatibility

Pillow requires a specific minimum Python version (currently 3.7+ for recent versions of Pillow). Check your Python version:

python --version

Check the Pillow PyPI page for the exact Python versions supported by the latest Pillow. If your Python is too old, you'll need to upgrade Python or install an older Pillow version compatible with your Python (e.g., pip install Pillow==<older_version>).

Use a Virtual Environment (Best Practice)

Conflicts with system-wide packages can cause installation problems. Always work within a virtual environment:

python3 -m venv venv
source venv/bin/activate
.\venv\Scripts\activate.bat
.\venv\Scripts\Activate.ps1

pip install --upgrade pip
pip install Pillow

Permissions Issues (--user or sudo)

If installing outside a virtual environment, you might lack permissions.

  • Recommended: Use the --user flag:
    pip install Pillow --user
  • Use with Caution: Use sudo (Linux/macOS):
    sudo pip install Pillow

Verbose Mode (-vvv)

For detailed error messages, run pip with the verbose flag:

pip install Pillow -vvv

Using Pillow in Your Code

Even though you install Pillow, you import components from the PIL namespace in your Python code, maintaining compatibility with older code written for PIL:

from PIL import Image # Import from PIL, even after installing Pillow

try:
    im = Image.open("your_image.jpg") # Replace with your image path
    print(im.format, im.size, im.mode)
    im.show() # Display the image (optional)
except FileNotFoundError:
    print("Error: Image file not found.")
except Exception as e:
    print(f"An error occurred: {e}")

Conclusion

The ERROR: Could not find a version that satisfies the requirement PIL error almost always means you should be installing the Pillow package instead of the outdated PIL.

  • Ensure any old PIL installations are removed, then install Pillow using pip install Pillow.
  • If you encounter further issues, upgrading pip, checking Python version compatibility, and using virtual environments are key troubleshooting steps.
  • Remember to import from PIL in your code after installing Pillow.
Navigation