Jupyter notebook server not working with latest Py

2019-05-31 07:31发布

So I received an update for PyCharm yesterday which has botched my Jupyter Notebook integration. Every time I try to run a jupyter notebook cell, I get hit with this prompt: http://localhost:8888/?token=

I run jupyter notebook list in the terminal to get list of running jupyter servers and its accompanying authenticating token. Even after entering this info into the earlier prompt, the cell refuses to run and returns with the token prompt again.

According to Using IPython/Jupyter Notebook with PyCharm, the url can be set in the Settings/Preferences dialog of PyCharm. However, as of this new update, the option to set notebook server url is missing.

By default, PyCharm asks me to follow a link when I try to run a jupyter cell for the first time. After following the link, PyCharm is supposed to get the token and run cells in the program instead of the browser. I realized that PyCharm starts with http://127.0.0.1:8888/?token=........token in the console, however, the prompt comes back with http://localhost:8888/?token=.

How do I solve this token issue?

1条回答
家丑人穷心不美
2楼-- · 2019-05-31 07:45

I had the same issue too, but I have resolved it.

I used Notebook 4.2.3 which is installed by Anaconda3-4.2.0 by default.

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

$ pip list | grep notebook
notebook (4.2.3)

From 4.3.0, notebook generates a token when running a notebook server for security reason.

See https://jupyter-notebook.readthedocs.io/en/latest/security.html#server-security.

PyCharm 2017.2 requires a token for notebook server URL, but notebook 4.2.3 unsupports a token. So, I upgraded notebook to 4.3.

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

After that, PyCharm shows the notebook kernel in the Run tool window when running a notebook server as below:

/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

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

It worked.

查看更多
登录 后发表回答