huggingface_hub: Token cannot be pasted in JupyterNotebook in VScode
Hi, I am using jupyternotebook via VScode. But When I run
from huggingface_hub import notebook_login
notebook_login()
I copy the Token, but I cannot paste it in the jupyternotebook in VScode. How to solve it?
!huggingface-cli login
doesn’t work either.
Thanks!
About this issue
- Original URL
- State: open
- Created 2 years ago
- Comments: 20 (9 by maintainers)
I was having the same issue in Jupyter and I was able to log in with:
from huggingface_hub import interpreter_login
interpreter_login()
For anyone landing on this issue, here is a summary of how to login with the Hub:
The preferred way: use
login
It will open the widget in a notebook and default to prompting the user in the terminal.
Without user input:
login(token="hf_***")
It’s also possible to login by providing directly the token. For example, you can get it from an environment variable.
In this example, if the environment is set, it is used. If not, the user is prompted.
Force interpreter or notebook usage
Use
interpreter_login
ornotebook_login
if you want to force it to use 1 or the other (instead of the auto-detection). When doing this, you cannot provide the token as input.For more details, here is the related package reference. Hope this can help future users 😃
As a temporary workaround, since you’re running on your personal machine and since the token is shared on a user-level, you should be able to do
huggingface-cli login
in your console and be logged-in in your notebook.Thank you. This method worked for me.
thank you very much!
Thanks. I use vs code to login huggingface and apply ur approach. It worked for me.