安装torch的时候报错:

error: uninstall-no-record-file

× Cannot uninstall torch None
╰─> The package's contents are unknown: no RECORD file was found for torch.

hint: You might be able to recover from this via: pip install --force-reinstall --no-deps torch==2.6.0

GPT给出的解答是:

  • 你已经手动删除了 PyTorch 的实际文件(所以 import torch 报错);

  • 但 pip 依然“以为” torch 安装过,因为它还保留了一条残缺的记录;

  • 所以你安装/卸载都会报 no RECORD file 的错误。

  • 既然 pip 的卸载功能失效了,你就不需要再卸载,直接重新安装并覆盖掉旧的记录即可。请执行pip install --force-reinstall --no-deps torch==2.6.0 -i https://pypi.tuna.tsinghua.edu.cn/simple(但是依然会报原来的错误)

此时执行pip show torch,得到以下信息:

Name: torch
Version: None
Summary: 
Home-page: 
Author: 
Author-email: 
License: 
Location: /user/anaconda3/lib/python3.12/site-packages
Requires: 
Required-by: timm, torchaudio, torchvision

我最后的解决方案是:
先找到torch的安装目录:python -c "import torch; print(torch.__file__)"
然后执行

rm -rf /user/anaconda3/lib/python3.12/site-packages/torch-*.dist-info
rm -rf /user/anaconda3/lib/python3.12/site-packages/torch
Logo

有“AI”的1024 = 2048,欢迎大家加入2048 AI社区

更多推荐