# ImportError: 无法从 'PIL' 导入名称 '_imaging'（保存图像需要 PIL）。

- **ID:** `python/matplotlib-agg-pillow-missing`
- **领域:** python
- **类别:** install_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

未安装 Pillow 或存在损坏的部分安装，导致 matplotlib 无法通过 Agg 后端保存 PNG/JPEG。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.x | active | — | — |

## 解决方案

1. **** (94% 成功率)
   ```
   pip uninstall -y PIL Pillow
pip install --no-cache-dir Pillow
   ```
2. **** (90% 成功率)
   ```
   fig.savefig('out.pdf')  # or 'out.svg'
   ```

## 无效尝试

- **** — The 'PIL' package on PyPI is a stub that raises an error; the correct package is Pillow. (95% 失败率)
- **** — Import order does not fix a broken _imaging C extension. (85% 失败率)
