Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token cannot be pasted in JupyterNotebook in VScode #752

Open
JingxinLee opened this issue Mar 9, 2022 · 20 comments
Open

Token cannot be pasted in JupyterNotebook in VScode #752

JingxinLee opened this issue Mar 9, 2022 · 20 comments

Comments

@JingxinLee
Copy link

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!

@osanseviero
Copy link
Contributor

cc @LysandreJik @sgugger

@sgugger
Copy link
Contributor

sgugger commented Mar 9, 2022

Could you explain a bit more why you can't paste it? On my side, I get the login window like on a regular notebook/colab and can paste the token then clean Login.

image

@JingxinLee
Copy link
Author

Could you explain a bit more why you can't paste it? On my side, I get the login window like on a regular notebook/colab and can paste the token then clean Login.

image

I copy the token and I want to paste it in the Token textbox, but nothing show in the textbox. I am sure I copied cause I can paste it anywhere except the Token textbox. Click login and Use Password button don't work.

@sgugger
Copy link
Contributor

sgugger commented Mar 9, 2022

Sounds like an issue with the widgets not properly working in VSCode. There is little we can do on our side to fix it, you should raise the issue on their repos.

@LysandreJik
Copy link
Member

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.

@StefanSamba
Copy link

I experienced the same issue. As a workaround, you could open your .ipynb in Jupyter Notebook, run notebook_login(), add your token and continue. After saving, you can continue in VSCode.

@Wauplin
Copy link
Contributor

Wauplin commented Aug 30, 2022

@stivennpe
Copy link

stivennpe commented Mar 23, 2023

I was having the same issue in Jupyter and I was able to log in with:
from huggingface_hub import interpreter_login

interpreter_login()

@Wauplin
Copy link
Contributor

Wauplin commented Mar 23, 2023

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.

from huggingface_hub import login

login()

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.

import os
from huggingface_hub import login

login(token=os.environ.get("HF_TOKEN"))

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 or notebook_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 :)

@jckuri
Copy link

jckuri commented Jun 12, 2023

I was having the same issue in Jupyter and I was able to log in with: from huggingface_hub import interpreter_login

interpreter_login()

Thank you.
This method worked for me.

@amee342
Copy link

amee342 commented Jun 23, 2023

I was having the same issue in Jupyter and I was able to log in with: from huggingface_hub import interpreter_login

interpreter_login()

Thanks. I use vs code to login huggingface and apply ur approach. It worked for me.

@michaelndam2023
Copy link

pour moi cela ne fonctionne pas sur Jupyter
ni from huggingface_hub import interpreter_login

interpreter_login()
ni
from huggingface_hub import notebook_login

notebook_login()

@michaelndam2023
Copy link

svp aidez moi

@michaelndam2023
Copy link

ni from huggingface_hub import interpreter_login

interpreter_login()

@Wauplin
Copy link
Contributor

Wauplin commented Nov 23, 2023

@michaelndam2023 Have you tested solutions presented in #752 (comment)? Also when you say "pour moi cela ne fonctionne pas sur Jupyter", can you be more explicit on the problem you are getting?

Also, please do not send 3 comments in a row requesting for help - this doesn't improve response time on an open-source project.

@michaelndam2023
Copy link

@Wauplin oui oui j'ai essayé mais en vain
l'on me dit jeton invalid et pourtant le jeton est correct
Invalid token passed!

@Wauplin
Copy link
Contributor

Wauplin commented Nov 23, 2023

Re-generate a new token on https://huggingface.co/settings/tokens.

@pechaut78
Copy link

pechaut78 commented Nov 28, 2023

Same Thing on a Mac here, both interpreter and notebook_login does not let paste, and login() runs forever in vscode

@Wauplin
Copy link
Contributor

Wauplin commented Nov 28, 2023

Hey @pechaut78, sorry for the inconvenient. This bug in VScode is not fixed. What you can do is to use the workarounds described in #752 (comment) and #752 (comment).

@nbllxbl
Copy link

nbllxbl commented Feb 27, 2024

I was having the same issue in Jupyter and I was able to log in with: from huggingface_hub import interpreter_login

interpreter_login()

thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests