Can't login huggingface through kaggle notebook

Hey guys , i am facing a problem and can’t login through token in kaggle notebook

!huggingface-cli login

I typed but it’s not taking input in Toke

In opposite Google colab working fine

I need to run file in kaggle

Any solution?

1 Like

I have the same problem here. Also the notebook_login() isn’t working (while it’s okay on colab).

Also noticed that on colab the huggingface_hub version is 0.11.1, but on kaggle is 0.10.1. Indeed installing directly from git doesn’t resolve the problem.

Actually i solved the problem transferring the files to the colab VM via the kaggle API and doing the push_to_hub on colab (i wanted to login to push the model to the hub). The kaggle API is super fast and super easy to setup, so this is my “production” solution :stuck_out_tongue:

I’m facing the same problem. How to upload a token to kaggle notebook and then use notebook_login()?

!sudo apt-get install expect -y # use ‘expect’ to handle interaction
!touch cmd.txt

context = “”"
spawn huggingface-cli login
expect “Username:”
send “your_username\r”
expect “Password:”
send “your_password\r”
interact
“”"
with open(‘cmd.txt’, ‘w’) as f:
f.write(context)

!expect cmd.txt

The version of hugging face on Kaggle is ‘0.10.1’, You may want to run your notebook in background mode where you of course won’t have access to input the token. or regardless, even if you are working in the editable mode you could simply do this:

!python -c “from huggingface_hub.hf_api import HfFolder; HfFolder.save_token(‘PUT YOUR TOKEN HERE’)”

This logs you in directly via code, you don’t need to manually fill in the token.

3 Likes