python data_error ai_generated true

错误:异常:回溯(最近一次调用最后):... zipfile.BadZipFile: 文件不是 zip 文件

ERROR: Exception: Traceback (most recent call last): ... zipfile.BadZipFile: File is not a zip file

ID: python/pip-cache-corrupted-unexpected-eof

其他格式: JSON · Markdown 中文 · English
80%修复率
87%置信度
0证据数
2024-02-20首次发现

版本兼容性

版本状态引入弃用备注
3.7 active — — —
3.8 active — — —
3.9 active — — —
3.10 active — — —
3.11 active — — —
3.12 active — — —

根因分析

pip 的 HTTP 缓存或 wheel 缓存中包含损坏的下载文件,通常是由于网络传输中断或磁盘写入错误导致。pip 尝试将缓存文件作为 zip 归档读取时失败。

English

pip's HTTP cache or wheel cache contains a corrupted download, often due to interrupted network transfer or disk write errors. pip attempts to read the cached file as a zip archive but fails.

generic

解决方案

  1. 95% 成功率
    Clear pip's cache: pip cache purge, then retry the installation.
  2. 90% 成功率
    Bypass cache for a single install: pip install --no-cache-dir <package>.

无效尝试

常见但无效的做法:

  1. 80% 失败

    Reinstalling pip does not clear the corrupted cache; the bad file remains and will be reused.

  2. 75% 失败

    Force reinstall still reads from cache first; corrupted cache causes the same error.