# ImportError：无法从 'packaging.utils' 导入名称 'canonicalize_name'

- **ID:** `python/packaging-utils-import-error`
- **领域:** python
- **类别:** module_error
- **验证级别:** ai_generated
- **修复率:** 80%

## 根因

函数 canonicalize_name 在较新版本中已移动到 packaging.utils，但安装的 packaging 库太旧。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| 3.8 | active | — | — |
| 3.9 | active | — | — |
| 3.10 | active | — | — |
| 3.11 | active | — | — |
| 3.12 | active | — | — |

## 解决方案

1. **** (95% 成功率)
   ```
   pip install --upgrade packaging
   ```
2. **** (85% 成功率)
   ```
   try: from packaging.utils import canonicalize_name; except ImportError: from packaging.utils import canonicalize_name as _; # handle manually
   ```

## 无效尝试

- **** — Downgrading may break other packages that depend on newer features. (40% 失败率)
- **** — The function simply does not exist in older versions; no alternative path works. (80% 失败率)
