【秒解决:huggingface_hub.utils._errors.LocalEntryNotFoundError】

报错详细

1)huggingface_hub.utils._errors.LocalEntryNotFoundError: An error happened while trying to locate the file on the Hub and we cannot find the requested files in the local cache. Please check your connection and try again or make sure your Internet connection is on
2)OSError: We couldn’t connect to ‘https://huggingface.co’ to load this file, couldn’t find it in the cached files and it looks like bert-base-uncased is not the path to a directory containing a file named config.json.

问题说明

在使用到huggingface时,下载连接不稳定导致,ConnectError。

解决方式

使用镜像网站链接解决稳定性问题,可使用以下其中一种方式改变huggingface网址
源码对应位置应该是这里

1)在python代码中加入以下代码
例如运行的代码为main.py,就在main.py代码里最上面添加

import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"
.
..
...
if __name__=='__main__':
	...

2)使用命令行修改环境变量并运行代码

#Linux
export HF_ENDPOINT="https://hf-mirror.com"
python xxx.py
#Windows Powershell
$env:HF_ENDPOINT = "https://hf-mirror.com"
python xxx.py

3)非入侵式修改环境变量运行代码

HF_ENDPOINT=https://hf-mirror.com python xxx.py

4)其他方式参考: https://hf-mirror.com

参考链接:链接

GitHub 加速计划 / hu / huggingface_hub
15
1
下载
The official CLI and Python client for the Hugging Face Hub.
最近提交(Master分支:3 个月前 )
0c7fd06f * [HfApi] Support gated repos hiding requester username/email Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * [HfApi] Split user/user_id validation into two explicit checks Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> * fix access requests for repos hiding usernames --------- Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Co-authored-by: Celina Hanouti <hanouticelina@gmail.com> 2 天前
c629fa34 * [Jobs] Fix hf jobs run losing logs and ignoring Ctrl+C * fix duplicated lines when following logs with tail * fix extra reconnect when the log stream ends with the job * fix tail resume dropping logs when the last tailed line is missing * fix 2s delay when following a finished job 2 天前
Logo

AtomGit 是由开放原子开源基金会联合 CSDN 等生态伙伴共同推出的新一代开源与人工智能协作平台。平台坚持“开放、中立、公益”的理念,把代码托管、模型共享、数据集托管、智能体开发体验和算力服务整合在一起,为开发者提供从开发、训练到部署的一站式体验。

更多推荐