ERROR
pip
data_error
ai_generated
true
ERROR: Exception: Traceback (most recent call last): ... json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0). The cache entry for 'https://pypi.org/simple/package/' is corrupted. Try deleting the cache with 'pip cache purge'.
ID: pip/cache-corruption-json-decode-error
95%Fix Rate
90%Confidence
1Evidence
2023-07-22First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| pip 23.0 | active | — | — | — |
| pip 23.1 | active | — | — | — |
| pip 23.2 | active | — | — | — |
| pip 24.0 | active | — | — | — |
Root Cause
The pip HTTP cache for the package index has a corrupted JSON file, likely due to an interrupted download or disk write error, causing pip to fail when parsing the cached response.
generic中文
软件包索引的 pip HTTP 缓存存在损坏的 JSON 文件,可能是由于下载中断或磁盘写入错误导致,使 pip 在解析缓存的响应时失败。
Official Documentation
https://pip.pypa.io/en/stable/topics/caching/Workarounds
-
95% success Clear the entire pip HTTP cache: pip cache purge. Then retry the installation. This removes all cached package index responses.
Clear the entire pip HTTP cache: pip cache purge. Then retry the installation. This removes all cached package index responses.
-
90% success If pip cache purge fails due to permission issues, manually delete the cache directory: rm -rf ~/.cache/pip (Linux/macOS) or rmdir /s %LocalAppData%\pip\cache (Windows). Then retry.
If pip cache purge fails due to permission issues, manually delete the cache directory: rm -rf ~/.cache/pip (Linux/macOS) or rmdir /s %LocalAppData%\pip\cache (Windows). Then retry.
-
80% success Use pip install --no-cache-dir as a temporary workaround to bypass the cache entirely: pip install --no-cache-dir package
Use pip install --no-cache-dir as a temporary workaround to bypass the cache entirely: pip install --no-cache-dir package
中文步骤
清除整个 pip HTTP 缓存:pip cache purge。然后重试安装。这将删除所有缓存的软件包索引响应。
如果 pip cache purge 因权限问题失败,请手动删除缓存目录:rm -rf ~/.cache/pip(Linux/macOS)或 rmdir /s %LocalAppData%\pip\cache(Windows)。然后重试。
使用 pip install --no-cache-dir 作为临时解决方法,完全绕过缓存:pip install --no-cache-dir package
Dead Ends
Common approaches that don't work:
-
Manually editing the cache JSON file to fix the corruption
95% fail
The cache file is often binary or partially written; manual editing is unreliable and may introduce further corruption.
-
Using pip install --no-cache-dir once but expecting the cache to be automatically repaired
80% fail
--no-cache-dir bypasses the cache for the current install but does not remove the corrupted entry; subsequent pip commands will still fail.
-
Deleting only the specific cache file without understanding the cache directory structure
60% fail
The cache may have multiple corrupted entries across different packages; a targeted delete may miss some.