Python 在 Pycharm 中的 Jupyter Notebook 身份验证令牌

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41736309/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-20 01:32:42  来源:igfitidea点击:

Jupyter Notebook authentication token while in Pycharm

pythonpycharmjupyter

提问by PutsandCalls

I am trying to use the Jupyter notebook in Pycharm, but I realized that in the new Jupyter update, there was the addition of tokens.

我正在尝试在 Pycharm 中使用 Jupyter notebook,但我意识到在新的 Jupyter 更新中,添加了令牌。

I am following the tutorial below from JetBrains.

我正在遵循以下来自JetBrains的教程。

With all the settings initiated with the virtual environment created and setting the URL as 127.0.0.1:8888, however, when I click on the run cell button, it follows that I get the following message from Jupyter Notebook asking:

使用创建的虚拟环境启动的所有设置并将 URL 设置为127.0.0.1:8888,但是,当我单击运行单元格按钮时,我从 Jupyter Notebook 收到以下消息,询问:

Please, enter your Jupyter Notebook URL and authentication token

请输入您的 Jupyter Notebook URL 和身份验证令牌

like this:

像这样:

PyCharm error message: Enter Jupyter Notebook URL authentication token

PyCharm 错误消息:输入 Jupyter Notebook URL 身份验证令牌

I looked it up on the Jupyter update blog and it says that my web browser should be initiated which generates a token for access, but I do not see that my browser is loaded here.

我在 Jupyter 更新博客上查了一下,它说应该启动我的 Web 浏览器,它会生成一个用于访问的令牌,但我没有看到我的浏览器已在此处加载。

Help would be greatly appreciated here.

在这里将不胜感激。

采纳答案by patemotter

Running jupyter notebook listwill display all of the running servers on your machine. So doing this in the terminal after starting a cell in PyCharm will result in output similar to Currently running servers: http://127.0.0.1:8888/?token=f85145dda03dc598bbbfa6e53b93cbcb27629ea00cfd2105 :: /home/.... which contains the appropriate token for authenticating.

运行jupyter notebook list将显示您机器上所有正在运行的服务器。因此,在 PyCharm 中启动单元后在终端中执行此操作将导致输出类似于 Currently running servers: http://127.0.0.1:8888/?token=f85145dda03dc598bbbfa6e53b93cbcb27629ea00cfd2105 :: /home/.... which 包含用于身份验证的适当令牌。

回答by Mr-IDE

  1. Edit/enter the URL as: http://localhost:8888(remove "?token="at the end) and click OK.
  2. A bubble prompt will appear near the top of your PyCharm window, saying "Cannot connect to Jupyter Notebook. Run Jupyter Notebook". It should look like this (depending on your color scheme):
  1. 编辑/输入 URL 为:(最后http://localhost:8888删除"?token=")并单击OK
  2. PyCharm 窗口顶部附近将出现一个气泡提示,提示“无法连接到 Jupyter Notebook。运行 Jupyter Notebook”。它应该是这样的(取决于你的配色方案):

PyCharm prompt: Cannot connect to Jypyter Notebook. Run Jupyter Notebook

PyCharm 提示:无法连接到 Jypyter Notebook。 运行 Jupyter Notebook

  1. Click on the link: "Run Jupyter Notebook"
  2. PyCharm will start the Jupyter server for you and it will create a new token. Look at View -> Tool Windows -> Run, to see details of the new token, and an optional URL to open in a web browser.
  1. 点击链接:“运行Jupyter Notebook”
  2. PyCharm 将为您启动 Jupyter 服务器并创建一个新令牌。查看视图 -> 工具窗口 -> 运行,查看新令牌的详细信息,以及在 Web 浏览器中打开的可选 URL。

More info: https://www.jetbrains.com/help/pycharm/using-ipython-jupyter-notebook-with-pycharm.html

更多信息:https: //www.jetbrains.com/help/pycharm/using-ipython-jupyter-notebook-with-pycharm.html

回答by debugging XD

The shortest way I found:
If you type jupyter notebookin a PowerShell terminal, PowerShell will automatically print out the localhost, port, and token that PyCharmneeds to run.

我找到的最短方法:
如果你jupyter notebook在 PowerShell 终端中输入,PowerShell 会自动打印出PyCharm需要运行的本地主机、端口和令牌。

You can run the command from PyCharm Terminal so it will go to the same interpreter if you have several.

您可以从 PyCharm 终端运行该命令,因此如果您有多个,它将​​转到同一个解释器。

回答by Finrod Felagund

For the people like me, who don't know where is the terminal->Another way which I find easier is:

对于像我这样不知道终端在哪里的人-> 我觉得更简单的另一种方法是:

1) open new Jupyter notebook in your browser. Look at the URL, there you can see your localhost (example: localhost:8889) and change the default one at PyCharm if necessary.

1) 在浏览器中打开新的 Jupyter 笔记本。查看 URL,您可以在那里看到您的 localhost(例如:localhost:8889),并在必要时更改 PyCharm 中的默认值。

2) for the token, while you are in the browser press F12 and then Ctrl + F and search for 'token'. It would be somewhere there in the html code, a long string of random numbers and letters.

2) 对于令牌,当您在浏览器中时按 F12,然后按 Ctrl + F 并搜索“令牌”。它会在 html 代码的某个地方,一长串随机数字和字母。