由于某些原因huggingface无法连接,还好有国内镜像,目前是可用的。 仅需在代码最上面加这两句就解决了!!!
import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"
1、下载依赖包
pip install -U huggingface_hub
2、修改环境配置(亲测加了https才能连上)
export HF_ENDPOINT=https://hf-mirror.com
修改原理 找到huggingface_hub依赖包下载配置文件,参考下面这个地址:
/path/to/env/site-packages/huggingface_hub/constants.py
如果环境中有HF_ENDPOINT的设定就会采用该设定作为前缀,即上面镜像的https://hf-mirror.com
而非默认的https://huggingface.co
。
参考:https://www.jianshu.com/p/645620c37c12 https://blog.csdn.net/qq_40277409/article/details/138566289 https://zhuanlan.zhihu.com/p/689290456 https://zhuanlan.zhihu.com/p/676420788
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有