jupyter / notebook

Jupyter Interactive Notebook
https://jupyter-notebook.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
11.8k stars 5.01k forks source link

Notebook Kernels can't seem to connect, but websockets work. #1692

Open mogthesprog opened 8 years ago

mogthesprog commented 8 years ago

Hey Guys,

Seeing some strange behaviour in the notebook and I have no idea where to begin troubleshooting it. Note that notebooks aren't working, while the terminal is working fine with no issues, so i think that rules out any websocket issues.

I installed the notebook with:

pip3 instal jupyter

And then I'm running the notebook with something like the following:

 jupyter-notebook --ip='*' --port=8080 --debug

Here is the output in the logs when i try to run a python kernel.

[D 09:32:50.143 NotebookApp] Using contents: services/contents
[W 09:32:50.150 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20160819093244 (10.193.11.61) 12.38ms referer=http://server.local.co.uk:8080/notebooks/Untitled.ipynb?kernel_name=python2
[D 09:32:50.226 NotebookApp] Found kernel python2 in /usr/local/share/jupyter/kernels
[D 09:32:50.227 NotebookApp] Starting kernel: [u'/usr/bin/python', u'-m', u'ipykernel', u'-f', u'/root/.local/share/jupyter/runtime/kernel-42f3d425-1ac8-4160-bc17-77121cae9f2f.json']
[D 09:32:50.233 NotebookApp] Connecting to: tcp://127.0.0.1:58357
[I 09:32:50.234 NotebookApp] Kernel started: 42f3d425-1ac8-4160-bc17-77121cae9f2f
[D 09:32:50.234 NotebookApp] Kernel args: {'kernel_name': u'python2', 'cwd': u'/root'}
[D 09:32:50.235 NotebookApp] 201 POST /api/sessions (10.193.11.61) 33.38ms
[D 09:32:50.236 NotebookApp] 200 GET /api/contents/Untitled.ipynb/checkpoints?_=1471599169782 (10.193.11.61) 0.89ms
[D 09:32:50.238 NotebookApp] 304 GET /static/components/MathJax/extensions/Safe.js?rev=2.6.0 (10.193.11.61) 1.14ms
[D 09:32:50.263 NotebookApp] Initializing websocket connection /api/kernels/42f3d425-1ac8-4160-bc17-77121cae9f2f/channels
[D 09:32:50.266 NotebookApp] Requesting kernel info from 42f3d425-1ac8-4160-bc17-77121cae9f2f
[D 09:32:50.266 NotebookApp] Connecting to: tcp://127.0.0.1:41871
[I 09:32:53.235 NotebookApp] KernelRestarter: restarting kernel (1/5)
[D 09:32:53.236 NotebookApp] Starting kernel: [u'/usr/bin/python', u'-m', u'ipykernel', u'-f', u'/root/.local/share/jupyter/runtime/kernel-42f3d425-1ac8-4160-bc17-77121cae9f2f.json']
[D 09:32:53.239 NotebookApp] Connecting to: tcp://127.0.0.1:58357
[I 09:32:56.242 NotebookApp] KernelRestarter: restarting kernel (2/5)
[D 09:32:56.243 NotebookApp] Starting kernel: [u'/usr/bin/python', u'-m', u'ipykernel', u'-f', u'/root/.local/share/jupyter/runtime/kernel-42f3d425-1ac8-4160-bc17-77121cae9f2f.json']
[D 09:32:56.246 NotebookApp] Connecting to: tcp://127.0.0.1:58357
[I 09:32:59.249 NotebookApp] KernelRestarter: restarting kernel (3/5)
[D 09:32:59.250 NotebookApp] Starting kernel: [u'/usr/bin/python', u'-m', u'ipykernel', u'-f', u'/root/.local/share/jupyter/runtime/kernel-42f3d425-1ac8-4160-bc17-77121cae9f2f.json']
[D 09:32:59.254 NotebookApp] Connecting to: tcp://127.0.0.1:58357
[W 09:33:00.267 NotebookApp] Timeout waiting for kernel_info reply from 42f3d425-1ac8-4160-bc17-77121cae9f2f
[D 09:33:00.268 NotebookApp] Opening websocket /api/kernels/42f3d425-1ac8-4160-bc17-77121cae9f2f/channels
[D 09:33:00.269 NotebookApp] Connecting to: tcp://127.0.0.1:41871
[D 09:33:00.269 NotebookApp] Connecting to: tcp://127.0.0.1:40140
[D 09:33:00.269 NotebookApp] Connecting to: tcp://127.0.0.1:57868
[I 09:33:02.256 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 42f3d425-1ac8-4160-bc17-77121cae9f2f restarted
[D 09:33:02.257 NotebookApp] Starting kernel: [u'/usr/bin/python', u'-m', u'ipykernel', u'-f', u'/root/.local/share/jupyter/runtime/kernel-42f3d425-1ac8-4160-bc17-77121cae9f2f.json']
[D 09:33:02.265 NotebookApp] Connecting to: tcp://127.0.0.1:58357
[W 09:33:05.267 NotebookApp] KernelRestarter: restart failed
[W 09:33:05.267 NotebookApp] Kernel 42f3d425-1ac8-4160-bc17-77121cae9f2f died, removing from map.
ERROR:root:kernel 42f3d425-1ac8-4160-bc17-77121cae9f2f restarted failed!
[D 09:33:05.293 NotebookApp] Websocket closed 42f3d425-1ac8-4160-bc17-77121cae9f2f:A2C434AC83E7477487E29518BC65C0A4
[W 09:33:05.306 NotebookApp] Kernel deleted before session
[W 09:33:05.306 NotebookApp] 410 DELETE /api/sessions/42591fa6-0741-4cf0-8046-352ccab66bcd (10.193.11.61) 2.22ms referer=http://server.local.co.uk:8080/notebooks/Untitled.ipynb?kernel_name=python2

Since it's struggling to connect via tcp I also tried --transport='ipc' with no dice... Any ideas?

mogthesprog commented 8 years ago

Update:

I played around with the version of notebok and downgraded to version 4.2.0:

pip3 uninstall jupyter
pip2 install notebook==4.2.0

And then I noticed the following messages in the log

[D 09:59:04.497 NotebookApp] Initializing websocket connection /api/kernels/10e8c215-4152-48ee-9160-cdedd70b44ff/channels
[D 09:59:04.500 NotebookApp] Requesting kernel info from 10e8c215-4152-48ee-9160-cdedd70b44ff
[D 09:59:04.500 NotebookApp] Connecting to: tcp://127.0.0.1:50264
/usr/bin/python: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed
[I 09:59:07.470 NotebookApp] KernelRestarter: restarting kernel (1/5)
[D 09:59:07.471 NotebookApp] Starting kernel: [u'/usr/bin/python', u'-m', u'ipykernel', u'-f', u'/root/.local/share/jupyter/runtime/kernel-10e8c215-4152-48ee-9160-cdedd70b44ff.json']
[D 09:59:07.477 NotebookApp] Connecting to: tcp://127.0.0.1:59295
/usr/bin/python: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed
[I 09:59:10.480 NotebookApp] KernelRestarter: restarting kernel (2/5)
[D 09:59:10.481 NotebookApp] Starting kernel: [u'/usr/bin/python', u'-m', u'ipykernel', u'-f', u'/root/.local/share/jupyter/runtime/kernel-10e8c215-4152-48ee-9160-cdedd70b44ff.json']
[D 09:59:10.484 NotebookApp] Connecting to: tcp://127.0.0.1:59295
/usr/bin/python: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed
[I 09:59:13.486 NotebookApp] KernelRestarter: restarting kernel (3/5)
[D 09:59:13.487 NotebookApp] Starting kernel: [u'/usr/bin/python', u'-m', u'ipykernel', u'-f', u'/root/.local/share/jupyter/runtime/kernel-10e8c215-4152-48ee-9160-cdedd70b44ff.json']
[D 09:59:13.490 NotebookApp] Connecting to: tcp://127.0.0.1:59295
/usr/bin/python: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed
[W 09:59:14.501 NotebookApp] Timeout waiting for kernel_info reply from 10e8c215-4152-48ee-9160-cdedd70b44ff
[D 09:59:14.502 NotebookApp] Opening websocket /api/kernels/10e8c215-4152-48ee-9160-cdedd70b44ff/channels
[D 09:59:14.502 NotebookApp] Connecting to: tcp://127.0.0.1:50264
[D 09:59:14.503 NotebookApp] Connecting to: tcp://127.0.0.1:51216
[D 09:59:14.503 NotebookApp] Connecting to: tcp://127.0.0.1:48014
[I 09:59:16.491 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 10e8c215-4152-48ee-9160-cdedd70b44ff restarted
[D 09:59:16.492 NotebookApp] Starting kernel: [u'/usr/bin/python', u'-m', u'ipykernel', u'-f', u'/root/.local/share/jupyter/runtime/kernel-10e8c215-4152-48ee-9160-cdedd70b44ff.json']
[D 09:59:16.495 NotebookApp] Connecting to: tcp://127.0.0.1:59295
/usr/bin/python: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed

Pay special attention to this line:

/usr/bin/python: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed

This error message isn't appearing in version 4.2.2, at least not for me. We had this problem before and fixed it with something like this:

RUN /usr/bin/yes | pip2 uninstall backports.shutil_get_terminal_size && \
                       pip install backports.shutil_get_terminal_size

I'm not sure what the issue is here, whether it's a problem with python2/3. Hopefully this helps someone else :)

Cheers.

takluyver commented 8 years ago

RUN /usr/bin/yes | pip2 uninstall backports.shutil_get_terminal_size && \ pip install backports.shutil_get_terminal_size

I'm not sure which Python your pip here uses, but you need to make sure that module is correctly installed for Python 2. It's not needed under Python 3.