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

从Pillow导入ImageCms时出现'_util'模块缺失错误求助

Fixing ImportError/ModuleNotFoundError When Importing ImageCms from Pillow 6.0.0

Looks like you're hitting two linked issues with Pillow 6.0.0's ImageCms module—let's break down how to fix this:

The easiest and most reliable fix is to upgrade to a newer version of Pillow, where both the _imagingcms dependency handling and the _util import path bug have been resolved. Run this command in your terminal:

pip install --upgrade pillow

After upgrading, try importing ImageCms again—it should work without errors.

Solution 2: Reinstall Pillow with LCMS2 Support (If You Can't Upgrade)

If you absolutely need to stick with Pillow 6.0.0, the root issue is likely that Pillow wasn't compiled with LCMS2 (the color management library ImageCms relies on) support. Here's how to fix that:

  • First, install the system-level LCMS2 development library:
    • On Ubuntu/Debian-based systems:
      sudo apt-get install liblcms2-dev
      
    • On macOS (using Homebrew):
      brew install lcms2
      
  • Then force a reinstall of Pillow to ensure it compiles with LCMS2 support:
    pip install --force-reinstall pillow==6.0.0
    
  • Additionally, you'll need to fix the broken import path in ImageCms.py:
    Locate the file at ~/anaconda3/lib/python3.6/site-packages/PIL/ImageCms.py, find line 27 where it says:
    from _util import deferred_error
    
    Change it to:
    from PIL._util import deferred_error
    
    This fixes the ModuleNotFoundError: No module named '_util' issue.

Why This Happens

  1. The first error (ImportError: cannot import name '_imagingcms') occurs because Pillow 6.0.0 requires the LCMS2 library to build the _imagingcms extension module. If LCMS2 wasn't present during installation, this module isn't compiled, causing the import failure.
  2. The second error (ModuleNotFoundError: No module named '_util') is a bug in Pillow 6.0.0's ImageCms.py—it tries to import _util directly instead of referencing it as PIL._util, which is the correct package path.

内容的提问来源于stack exchange,提问作者G M

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.06 23:04:08