安装PIL模块失败及执行from PIL import Image导入时出现版本匹配错误的技术求助
Hey, I’ve run into this exact issue before! The problem here is super straightforward: PIL has been discontinued for years—it’s no longer available on PyPI, which is why you’re getting that "no matching distribution" error.
Instead, everyone uses Pillow now, which is a maintained fork of PIL that’s fully compatible with the old PIL code. Here’s how to fix this:
First, if you have any leftover (broken) PIL installation, uninstall it with:
pip uninstall PIL(You might get a message saying it’s not installed—don’t worry, that’s totally fine.)
Next, install Pillow using the correct package name (note it’s lowercase):
pip install pillowIf you’re using Python 3 and have both Python 2 and 3 installed, use
pip3instead to make sure it installs to the right environment.Finally, keep using your original import line:
from PIL import ImagePillow keeps the
PILnamespace for compatibility, so your existing code won’t need any changes.
If you run into permissions issues (like "access denied"), try adding --user to the install command to install it for your user account only:
pip install pillow --user
内容的提问来源于stack exchange,提问作者Tal Folkman

