Could not find version that satisfies the requirement PIL

avatar
Borislav Hadzhiev

Last updated: Apr 9, 2024
4 min

banner

# Could not find version that satisfies the requirement PIL

The error "Could not find a version that satisfies the requirement PIL" occurs when we try to pip install the PIL package.

To solve the error, install Pillow which is a maintained fork of PIL and can be used as a drop-in replacement.

could not find version that satisfies requirement pil

shell
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none) ERROR: No matching distribution found for PIL

# Uninstall PIL before installing Pillow

Open your terminal in your project's root directory and install the Pillow module which is a maintained fork of PIL.

If you have PIL installed, make sure to uninstall it first as the two packages cannot co-exist in the same environment.

shell
# ๐Ÿ‘‡๏ธ Before installing Pillow, uninstall PIL. pip uninstall PIL # ๐Ÿ‘‡๏ธ In a virtual environment or using Python 2 pip install Pillow # ๐Ÿ‘‡๏ธ For python 3 (could also be pip3.10 depending on your version) pip3 install Pillow # ๐Ÿ‘‡๏ธ If you get a permissions error sudo pip3 install Pillow # ๐Ÿ‘‡๏ธ If you don't have pip in your PATH environment variable python -m pip install --upgrade Pillow # ๐Ÿ‘‡๏ธ For python 3 (could also be pip3.10 depending on your version) python3 -m pip install --upgrade Pillow # ๐Ÿ‘‡๏ธ For Anaconda conda install -c conda-forge pillow

Notice that we made sure to uninstall PIL before installing Pillow.

After you install the Pillow package, try importing it as follows.

main.py
from PIL import Image im = Image.open("hopper.ppm") print(im.format, im.size, im.mode)

# Upgrade your version of pip

If the error persists, upgrade pip and try to re-run the pip install Pillow command.

Here are the commands for upgrading pip on all operating systems.

Which command works depends on your operating system and your version of Python.

shell
# ๐Ÿ‘‡๏ธ If you have pip already installed pip install --upgrade pip # ๐Ÿ‘‡๏ธ If your pip is aliased as pip3 (Python 3) pip3 install --upgrade pip # ๐Ÿ‘‡๏ธ If you don't have pip in your PATH environment variable python -m pip install --upgrade pip # ๐Ÿ‘‡๏ธ If you don't have pip in your PATH environment variable python3 -m pip install --upgrade pip # ๐Ÿ‘‡๏ธ If you have easy_install easy_install --upgrade pip # ๐Ÿ‘‡๏ธ If you get a permissions error sudo easy_install --upgrade pip # ๐Ÿ‘‡๏ธ If you get a permissions error when upgrading `pip` pip install --upgrade pip --user # ๐Ÿ‘‡๏ธ Upgrade pip scoped to the current user (if you get a permissions error) python -m pip install --user --upgrade pip python3 -m pip install --user --upgrade pip # ๐Ÿ‘‡๏ธ Installing directly from get-pip.py (MacOS and Linux) curl https://bootstrap.pypa.io/get-pip.py | python # ๐Ÿ‘‡๏ธ If you get permissions issues curl https://bootstrap.pypa.io/get-pip.py | sudo python # ๐Ÿ‘‡๏ธ Alternative for Ubuntu/Debian sudo apt-get update && apt-get upgrade python-pip # ๐Ÿ‘‡๏ธ Alternative for Red Hat / CentOS / Fedora sudo yum install epel-release sudo yum install python-pip sudo yum update python-pip

If you get the error "ModuleNotFoundError: No module named 'pip' in Python", check out my other article:

Try running the pip install Pillow command after upgrading pip.

shell
pip install Pillow --upgrade pip3 install Pillow --upgrade python3 -m pip install Pillow --upgrade

upgrade pillow version

# Check if your Python version is supported by Pillow

If that didn't help, check if your Python version is supported by Pillow.

The Pillow package supports Python versions 3.7+.

You can open the pypi page of Pillow and view the supported Python versions in the sidebar on the left, under Meta > Requires.

Pillow supported python versions

You can check your Python version with the python --version command.

shell
python --version python3 --version

get python version

If you have an older Python version than 3.7, download the latest version from the official python.org website and run the installer.

Make sure to tick the following options if you get prompted:

  • Install launcher for all users (recommended)
  • Add Python to PATH (this adds Python to your PATH environment variable)

Once you have a Python version in the supported range, try installing Pillow.

shell
pip install Pillow --upgrade pip3 install Pillow --upgrade python3 -m pip install Pillow --upgrade

If that didn't help, try installing the package in a virtual environment scoped to Python 3.

# Try installing the package in a virtual environment

Another thing that might help is to create a virtual environment if you don't already have one.

shell
# ๐Ÿ‘‡๏ธ Use the correct version of Python when creating VENV python3 -m venv venv # ๐Ÿ‘‡๏ธ Activate on Unix or MacOS source venv/bin/activate # ๐Ÿ‘‡๏ธ Activate on Windows (cmd.exe) venv\Scripts\activate.bat # ๐Ÿ‘‡๏ธ Activate on Windows (PowerShell) venv\Scripts\Activate.ps1 # ๐Ÿ‘‡๏ธ Upgrade pip pip install --upgrade pip # ๐Ÿ‘‡๏ธ Install Pillow in your virtual environment pip install Pillow

If the python3 -m venv venv command doesn't work, try running one of the following 2 commands:

  • python -m venv venv
  • py -m venv venv

Make sure to use the correct activation command depending on your operating system.

Your virtual environment will use the version of Python that was used to create it.

If that didn't help, try to scope the command to the specific user.

The --user option installs the package in the user's home directory.

shell
pip install Pillow --user pip3 install Pillow --user python3 -m pip install Pillow --user
The command basically installs the package scoped to the specific user, not for the entire system. This helps with permission issues.

If you get a permissions error, try running the command with the --user flag or with sudo.

shell
sudo pip install Pillow sudo pip3 install Pillow sudo python3 -m pip install Pillow

If that didn't help, try running the command in verbose mode.

# Try running pip install Pillow in verbose mode

If none of the suggestions helped, try running the pip install command in verbose mode.

shell
pip install Pillow -vvv pip3 install Pillow -vvv python -m pip install Pillow -vvv

The -v option stands for verbose mode and can be used up to 3 times.

When the pip install command is run in verbose mode, the command shows more output and how the error occurred.

I wrote a book in which I share everything I know about how to become a better, more efficient programmer.
book cover
You can use the search field on my Home Page to filter through all of my articles.

Copyright ยฉ 2024 Borislav Hadzhiev