You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行pip安装requirements.txt依赖提示路径不存在报错如何解决

问题场景
  • 运行环境:Anaconda Prompt (base) 环境
  • 执行的依赖安装命令:
(base) C:\Users\Lenovo>pip install -r D:\autoencoder\Website_by_python\requirements.txt
  • 返回报错信息:
Processing c:\tmp\build\80754af9\backports.functools_lru_cache_1618170165463\work
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\tmp\\build\\80754af9\\backports.functools_lru_cache_1618170165463\\work'
触发原因

pip本地缓存残留了backports.functools_lru_cache包的失效临时构建路径,安装时pip优先读取这条无效缓存记录,尝试访问已经被系统清理的tmp临时目录,触发文件不存在错误;少数情况是requirements.txt内误写了该依赖的本地绝对路径,而非公网源的标准包版本标识。

解决方案

按以下顺序排查即可:

  • 第一步清理pip损坏的本地缓存,执行命令:
    pip cache purge
    
    清理完成后重新执行原安装命令,多数场景下可直接解决问题。
  • 如果清缓存后仍报错,安装时增加--no-cache-dir参数,强制pip跳过本地缓存,直接从配置的PyPI源拉取官方发布的正式包,命令如下:
    pip install -r D:\autoencoder\Website_by_python\requirements.txt --no-cache-dir
    
  • 以上操作无效时,打开D:\autoencoder\Website_by_python\requirements.txt,全文搜索是否存在带C:\tmp\build字样的依赖行,找到后直接删除该行,替换为该包的标准版本声明即可:
    backports.functools-lru-cache>=1.6.1
    
    保存文件后重新执行安装命令。

补充说明:如果你当前使用的Python版本 >= 3.2,lru_cache能力已经内置在标准库functools中,backports.functools_lru_cache是仅为Python2版本做兼容的回退包,直接从requirements.txt中删除该依赖项也不会影响代码正常运行。


内容的提问来源于stack exchange,提问作者Panasun

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.27 16:24:34