Pillow is a maintained fork of PIL, so I recommend using Pillow. But you can't have both installed at the same time.

  1. First, remove both PIL and Pillow.

  2. Then install Pillow with pip install pillow (although, depending on platform, you may need some prerequisites).

  3. Then make sure code is using from PIL import Image rather than import Image.

Answer from Hugo on Stack Overflow
🌐
Reddit
reddit.com › r/learnpython › import pil does not work when pillow is installed via pip
r/learnpython on Reddit: Import PIL does not work when Pillow is installed via pip
February 19, 2023 -

I'm coding a music player in python for learning and I see that PIL needs to be used for the "Logo.png" error (which I have the .png file for it). But the "Import PIL" doesn't work and spits out the "couldn't be resolved" error. Even though I have installed Pillow (and upgraded it). I'm using the Tkinter module for this project btw. Another thought I had was bypassing the PIL/Pillow module entirely and creating a more primitive version just to import images. But I haven't found any related instructions on getting python to recognize image files, especially for importing to projects.

Discussions

ModuleNotFoundError: No module named 'PIL'
#! /usr/bin/python3 # On 10/4/22 I installed version Python 3.10.7 # Does not work # Traceback (most recent call last): # File "/home/andy/Python/png2jpg.py", line 10, in # from PIL import Image # ModuleN… More on discuss.python.org
🌐 discuss.python.org
19
1
October 5, 2022
python - how to install PIL with pip? - Stack Overflow
The problem could be that you are not running the same python interpreter. You first need to find the path to the python executable that is interpreting your python scripts. ... This will print the path to the python executable that is interpreting your python scripts. Now, you can install pillow in the found path as follows: ... If you are sure that you already installed pillow use this command pip ... More on stackoverflow.com
🌐 stackoverflow.com
python 3 - How am I supposed to install Pillow (not PIL) on Raspberry Pi OS? - Raspberry Pi Stack Exchange
Bring the best of human thought ... at your work. Explore Stack Internal ... This is a new Pi 5 running Raspberry Pi OS and Python 3.11. I have a dependency on Pillow. Definitely not PIL because PIL lacks certain features - specifically ImageTk: ImportError: cannot import name 'ImageTk' from 'PIL'. pip install pillow returns ... More on raspberrypi.stackexchange.com
🌐 raspberrypi.stackexchange.com
May 14, 2024
python - Cannot Install PIL using Pycharm - Stack Overflow
Bring the best of human thought and AI automation together at your work. Explore Stack Internal ... Closed 6 years ago. Hi I'am trying to install PIL using Pycharm. I am using pip 19.1.1 ... Collecting PIL ERROR: Could not find a version that satisfies the requirement PIL (from versions: none) ... More on stackoverflow.com
🌐 stackoverflow.com
🌐
GitHub
gist.github.com › devchandansh › 7b091e9109e53b92045478ae118e864a
Could not find a version that satisfies the requirement PIL (from versions: none) ERROR: No matching distribution found for PIL · GitHub
Use Pillow instead, as PIL is basically dead or not responding. ... if you are working in VS Code just change the python interpreter from 3.10 to 3.9 base conda it will work properly on 3.9 base conda.
🌐
Raspberry Pi Forums
forums.raspberrypi.com › board index › using the raspberry pi › beginners
Trouble installing Pillow / PIL - Raspberry Pi Forums
November 10, 2021 - Install Pillow For Ubuntu 13.10+: sudo pip3 install Pillow and for 13.04-: sudo pip-3.2 install Pillow I get an error: Invalid operation pip3 After doing 'sudo apt-get install python3-pip' on Raspbian, I then have a pip-3.2 command available... ... AndrewS wrote: After doing 'sudo apt-get install python3-pip' on Raspbian, I then have a pip-3.2 command available... That worked!
Find elsewhere
🌐
Bobby Hadz
bobbyhadz.com › blog › python-no-module-named-pil
ModuleNotFoundError: No module named 'PIL' in Python [Fixed] | bobbyhadz
April 8, 2024 - If the error persists, make sure you haven't named a module in your project as pil.py because that would shadow the original Pillow module. You also shouldn't be declaring a variable named PIL as that would also shadow the original module.
Top answer
1 of 1
2

you might try to create a virtual environment and install pillow there.

python -m venv ~/myvenv
source ~/myvenv/bin/activate
pip install -U pip
pip install pillow

then use ~/myvenv/bin/python to run the script requiring pillow.

Does this work or do you get the same kind of error message (error: externally-managed-environment )

I'm no expert concerning the "externally-managed-environment" in fact I read it the first time in your post. But a small search seems to indicate that this is a recent enhancement that tries to avoid conflicts between packages installed with apt and packages installed with pip.

So my suggestion to use a venv doesn't seem that bad.

I read https://itsfoss.com/externally-managed-environment/ and it says amongst many other things:

Ubuntu 23.04, Fedora 38 and probably other recent distribution versions are implementing this enhancement on the use of Python packages.

The change has been done to avoid the "conflict between OS package managers and Python-specific package management tools like pip. These conflicts include both Python-level API incompatibilities and conflicts over file ownership."

What are your options?

You can do three things when you try to install a Python package and see this error.

Install the native package
Create virtual environments in Python
Use Pipx (recommended)

I never tried the option pipx (but I it seems it will also create a virtualenv, + some more automatic stuff) However I think pipx works only for executables and not for libraries, so I'd stick with a vinv or a virtualenv at least utnil pipx is better understood

🌐
Finxter
blog.finxter.com › home › learn python blog › pip install pil/pillow – a helpful illustrated guide
PIP Install PIL/Pillow - A Helpful Illustrated Guide - Be on the Right Side of Change
November 24, 2022 - 💡 If you have only one version of Python installed: pip install pillow 💡 If you have Python 3 (and, possibly, other versions) installed: pip3 install pillow 💡 If you don't have PIP or it doesn't work python -m pip install pillow python3 -m pip install pillow 💡 If you have Linux and you need to fix permissions (any one): sudo pip3 install pillow pip3 install pillow --user 💡 If you have Linux with apt sudo apt install pillow 💡 If you have Windows and you have set up the py alias py -m pip install pillow 💡 If you have Anaconda conda install -c anaconda pillow 💡 If you have Jupyter Notebook !pip install pillow !pip3 install pillow
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-fix-modulenotfounderror-no-module-named-pil-in-python
How to Fix "ModuleNotFoundError: No Module Named 'PIL'" in Python - GeeksforGeeks
July 23, 2025 - However, you may encounter the error ModuleNotFoundError: No module named 'PIL', which can prevent your script from running. This usually occurs when Pillow is not installed properly or the import statement is incorrect.
🌐
PyPI
pypi.org › project › pillow
pillow · PyPI
If you're not sure which to choose, learn more about installing packages. ... Filter files by name, interpreter, ABI, and platform. If you're not sure about the file name format, learn more about wheel file names. ... pillow-12.2.0-pp311-pypy311_pp73-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl ...
      » pip install pillow
    
Published   Apr 01, 2026
Version   12.2.0
🌐
GitHub
github.com › python-pillow › Pillow › discussions › 7532
Exception: You don't have PIL installed. Please install PIL or Pillow>=8.1.1 · python-pillow/Pillow · Discussion #7532
This comment and the error message make me think you might have downloaded the wrong version of Pillow for your Python version (e.g. Python 3.10 version of Pillow for Python 3.11 or vice versa, or a x86 build of Pillow for x86_64 Python). As @radarhere said above, you should not need to manually install packages since tools such as pip can automatically download the correct version.
Author   python-pillow
🌐
GitHub
github.com › python-pillow › Pillow › issues › 5868
"pip install Pillow" command not working. Returns an error requiring zlib · Issue #5868 · python-pillow/Pillow
December 4, 2021 - I ran "pip install Pillow " in a virtualenv but it returns an error about zlip dependency I expected it to install Pillow in the virtual environment but it doesn't Pillow is a dependency for Django-filer which I obviously need for a djna...
Author   hero4barca