Jupyter笔记本服务器无法使用最新的PyCharm 2017.2更新。我该如何解决这个问题?

时间:2017-07-28 09:49:49

标签: pycharm jupyter-notebook

所以我昨天收到了PyCharm的更新,这让我的Jupyter Notebook集成了。每当我尝试运行jupyter笔记本单元格时,我都会收到此提示:http://localhost:8888/?token=

我在终端中运行jupyter notebook list以获取正在运行的jupyter服务器及其附带的身份验证令牌的列表。即使将此信息输入到先前的提示中,单元格也会拒绝运行并再次返回令牌提示。

根据Using IPython/Jupyter Notebook with PyCharm,可以在PyCharm的Settings/Preferences dialog中设置网址。但是,从此新更新开始,缺少设置笔记本服务器URL的选项。

默认情况下,当我第一次尝试运行jupyter单元时,PyCharm要求我关注链接。在关注链接后,PyCharm应该获取令牌并在程序中运行单元而不是浏览器。我意识到PyCharm在控制台中以http://127.0.0.1:8888/?token=........token开头,然而,提示返回http://localhost:8888/?token=

如何解决此令牌问题?

1 个答案:

答案 0 :(得分:1)

我也有同样的问题,但我已经解决了。

我使用的是默认情况下由Anaconda3-4.2.0安装的Notebook 4.2.3。

$ pyenv versions
  system
* anaconda3-4.2.0 (set by /Users/akiyoko/.pyenv/version)

$ pip list | grep notebook
notebook (4.2.3)

从4.3.0开始,笔记本电脑出于安全原因运行笔记本电脑服务器时会生成令牌。

请参阅https://jupyter-notebook.readthedocs.io/en/latest/security.html#server-security

PyCharm 2017.2需要笔记本服务器URL的令牌,但笔记本4.2.3不支持令牌。所以,我将笔记本升级到4.3。

$ pip install notebook==4.3
$ pip list | grep notebook
notebook (4.3.0)

之后,PyCharm在运行笔记本服务器时在运行工具窗口中显示笔记本内核,如下所示:

/Users/akiyoko/.pyenv/versions/anaconda3-4.2.0/bin/python /Users/akiyoko/.pyenv/versions/anaconda3-4.2.0/bin/jupyter-notebook --no-browser --ip 127.0.0.1 --port 8888 --port-retries=0
[I 11:41:22.657 NotebookApp] [nb_conda_kernels] enabled, 2 kernels found
[I 11:41:23.517 NotebookApp] [nb_anacondacloud] enabled
[I 11:41:23.526 NotebookApp] [nb_conda] enabled
[I 11:41:23.661 NotebookApp] ✓ nbpresent HTML export ENABLED
[W 11:41:23.661 NotebookApp] ✗ nbpresent PDF export DISABLED: No module named 'nbbrowserpdf'
[I 11:41:23.669 NotebookApp] Serving notebooks from local directory: /Users/akiyoko/PycharmProjects/jupyter-test
[I 11:41:23.669 NotebookApp] 0 active kernels 
[I 11:41:23.669 NotebookApp] The Jupyter Notebook is running at: http://127.0.0.1:8888/?token=e0393bd13f97aa6408607df24a7c13b6341d80e841d0c8ad

请参阅https://www.jetbrains.com/help/pycharm/running-ipython-jupyter-notebook-cells.html

有效。