admin管理员组

文章数量:1393052

I am having a very hard time with login to huggingface via pycharm on macos.

The below code snippet never works :-

from huggingface_hub import login

login("<HF_TOKEN>")

I get the error:

exceptions.SSLError: (MaxRetryError("HTTPSConnectionPool(host='huggingface.co', port=443): Max retries exceeded with url: /api/whoami-v2

If I add the following code snipped before the login call:-

import warnings

warnings.filterwarnings('ignore')


def backend_factory() -> requests.Session:
    session = requests.Session()
    session.verify = False
    return session


configure_http_backend(backend_factory=backend_factory)
os.environ['CURL_CA_BUNDLE'] = ''
os.environ['HF_ENDPOINT'] = ''
# os.environ['HF_HUB_OFFLINE'] = '0'
try:
    _create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
    pass
else:
    ssl._create_default_https_context = _create_unverified_https_context

login("<HF_TOKEN>")

Then I get the error:

fHubHTTPError('401 Client Error: Unauthorized for url:

requests.exceptions.HTTPError: Invalid user token. The token stored is invalid. Please run huggingface-cli login to update it.

And sometimes I get invalid token error. I have also observed that with notebook_login() it seems to work, but I want to work with pycharm and not able to make the login work.

I have tried creating all types of token at [Read/ Write/Fine grained]

It could be some issue with my macos - any help is highly appreciated in resolving this.

本文标签: huggingfaceHugging face login on macosStack Overflow