目录
设置环境变量
python%20%E4%B8%8B%E8%BD%BD%EF%BC%9A-toc" style="margin-left:40px;">python 下载无token:
python%20%E4%B8%8B%E8%BD%BD%E5%8A%A0token-toc" style="margin-left:40px;">python 下载加token
常见报错
设置环境变量
Linux
export HF_ENDPOINT=https://hf-mirror.com
- Windows Powershell
$env:HF_ENDPOINT = "https://hf-mirror.com"
pip install -U huggingface_hub
huggingface-cli download --h
$env:HF_ENDPOINT = "https://hf-mirror.com"
huggingface-cli download --resume-download gpt2--local-dir gpt2
python%20%E4%B8%8B%E8%BD%BD%EF%BC%9A">python 下载无token:
报错,和浏览器的一样,401错误
python">
# 设置环境变量
import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"# 代码下载
from huggingface_hub import hf_hub_download
hf_hub_download(repo_id="black-forest-labs/FLUX.1-dev" ,filename="model_index.json" ,local_dir="./qafacteval")
python%20%E4%B8%8B%E8%BD%BD%E5%8A%A0token">python 下载加token
python">import os
os.environ["HF_ENDPOINT"] = "https://hf-mirror.com"from huggingface_hub import snapshot_downloadlocal_dir = r"B:\data\aigc1"
repo_id = "black-forest-labs/FLUX.1-dev"
token = "xxxxxx"snapshot_download(repo_id=repo_id, local_dir=local_dir, resume_download=True, local_dir_use_symlinks=False, token=token)# 没成功:
# from huggingface_hub import hf_hub_download
# hf_hub_download(repo_id="black-forest-labs/FLUX.1-dev" ,filename="model_index.json" ,local_dir="./qafacteval")
常见报错
- huggingface-cli: error: invalid choice: ‘download’ (choose from ‘env’, ‘login’, ‘whoami’, ‘logout’, ‘repo’, ‘lfs-enable-largefiles’, ‘lfs-multipart-upload’, ‘scan-cache’, ‘delete-cache’)
- ModuleNotFoundError: No module named ‘chardet’
- 安装对应模块即可:
pip install chardet
- 安装对应模块即可: