end0tknr's kipple - web写経開発

太宰府天満宮の狛犬って、妙にカワイイ

proxy配下における huggingface_hub for python の ssl エラー

内部的には、requests for python を利用していますので、 一時的に python3.11/Lib/site-packages/huggingface_hub/utils/_http.py の 306行目にある以下に verify=False を加えることで回避できます。

OLD) response = session.request(method=method, url=url, **kwargs)
NEW) response = session.request(method=method, url=url, **kwargs, verify=False)

ただし、上記の verify=False だけでは、実行時に以下のwarningが表示されますので _http.py に urllib3.disable_warnings(InsecureRequestWarning) 等の3行も加えておくとよいです。

python3.11\Lib\site-packages\urllib3\connectionpool.py:1097:
InsecureRequestWarning: Unverified HTTPS request is being made to host 'huggingface.co'.
Adding certificate verification is strongly advised.
See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#tls-warnings
  warnings.warn(
import urllib3
from urllib3.exceptions import InsecureRequestWarning
urllib3.disable_warnings(InsecureRequestWarning)