简体   繁体   English

列出正在运行的 Jupyter 笔记本和令牌

[英]List running Jupyter notebooks and tokens

How do you check the login tokens for all running jupyter notebook instances?您如何检查所有正在运行的 jupyter notebook 实例的登录令牌?

Example: you have a notebook running in tmux or screen permanently, and login in remotely through ssh .示例:您有一个笔记本在tmuxscreen永久运行,并通过ssh远程ssh Sometimes, particularly if you're logging in after a long time, the token is requested again in order to access the notebook session.有时,特别是当您在很长时间后登录时,会再次请求令牌以访问笔记本会话。 How do you get hold of the token without having to kill and restart the notebook session with a new token?如何在不必使用新令牌终止和重新启动笔记本会话的情况下获取令牌?

UPDATE更新

You can now just run jupyter notebook list in the terminal to get the running jupyter sessions with tokens.您现在可以在终端中运行jupyter notebook list以获取正在运行的带有令牌的 jupyter 会话。

在此处输入图片说明

Take care that you are within the right environment (conda, virtualenv etc.) otherwise the sessions will list without the associated tokens.请注意您处于正确的环境(conda、virtualenv 等)中,否则会话将在没有关联令牌的情况下列出。 Eg: The above reference screenshot is from the conda environment.例如:上面的参考截图来自 conda 环境。

Old answer:旧答案:

Run ipython and enter the following:运行 ipython 并输入以下内容:

> ipython
[1] : system("jupyter" "notebook" "list")
Out[1]: 
['Currently running servers:','http://localhost:8895/token=067470c5ddsadc54153ghfjd817d15b5d5f5341e56b0dsad78a :: /u/user/dir']

If the notebook is running on a remote server, you will have to login in to that server first before running ipython.如果笔记本在远程服务器上运行,则必须先登录该服务器,然后才能运行 ipython。

One easy solution (that can save you time by avoiding opening a new terminal) is from the same terminal you are running the notebook to hit (ONLY ONCE!! - cause twice would kill the running server)一个简单的解决方案(可以通过避免打开新终端来节省您的时间)是从您运行笔记本电脑的同一个终端点击(仅一次!! - 因为两次会杀死正在运行的服务器)

Ctrl + C  

By doing that the full link to your notebook will appear (along with the token!) and a prompt asking you to confirm shutting down.通过这样做,将出现指向您的笔记本的完整链接(以及令牌!)并提示您确认关闭。 Just answer no ( n and enter) or do nothing and after 5 seconds the operation will resume.只需回答 no( n并输入)或什么都不做,5 秒后操作将恢复。 In the meanwhile you would have been able to retrieve the link and/or the token you need.同时,您将能够检索所需的链接和/或令牌。

Just right click on the jupyter notebook logo in the currently running server, you probably have a server running already, then click on copy link, then paste the link in a text editor, maybe MS word, you will see the token in the link, copy and paste where token is required.只需右键单击当前正在运行的服务器中的 jupyter notebook 徽标,您可能已经有一台服务器正在运行,然后单击复制链接,然后将链接粘贴到文本编辑器中,也许是 MS word,您将在链接中看到令牌,复制并粘贴到需要令牌的地方。 It will work.它会起作用。

Use this command使用这个命令

$ jupyter server list

It will display the currently running servers for both jupyter lab and jupyter notebook along with the tokens.它将显示jupyter labjupyter notebook当前运行的服务器以及令牌。

For running python code in jupyter notebook...we need token id which we can obtain from the terminal by just typing jupyter notebook provided your path has been configured... If not then set your path right first.为了在 jupyter notebook 中运行 python 代码……我们需要令牌 ID,只要您的路径已配置,我们只需键入jupyter notebook即可从终端获取该 ID……如果没有,请先设置您的路径。

样品

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM