Last updated: Apr 9, 2024
Reading timeยท4 min
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.
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none) ERROR: No matching distribution found for PIL
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.
# ๐๏ธ 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.
from PIL import Image im = Image.open("hopper.ppm") print(im.format, im.size, im.mode)
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.
# ๐๏ธ 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
.
pip install Pillow --upgrade pip3 install Pillow --upgrade python3 -m pip install Pillow --upgrade
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
.
You can check your Python version with the python --version
command.
python --version python3 --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:
Once you have a Python version in the supported range, try installing Pillow
.
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.
Another thing that might help is to create a virtual environment if you don't already have one.
# ๐๏ธ 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.
pip install Pillow --user pip3 install Pillow --user python3 -m pip install Pillow --user
If you get a permissions error, try running the command with the --user
flag
or with sudo
.
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.
If none of the suggestions helped, try running the pip install
command in
verbose mode.
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.