You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装PIL模块失败及执行from PIL import Image导入时出现版本匹配错误的技术求助

解决PIL安装与导入失败的问题

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 pillow
    

    If you’re using Python 3 and have both Python 2 and 3 installed, use pip3 instead to make sure it installs to the right environment.

  • Finally, keep using your original import line:

    from PIL import Image
    

    Pillow keeps the PIL namespace 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

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 09:28:11