ipython / ipykernel

IPython Kernel for Jupyter
https://ipykernel.readthedocs.io/en/stable/
BSD 3-Clause "New" or "Revised" License
654 stars 370 forks source link

Unable to start kernel on python 2.7 with ipython juypter notebook #194

Open shyamalschandra opened 8 years ago

shyamalschandra commented 8 years ago

What should I do?

[TerminalIPythonApp] WARNING | Subcommand `ipython notebook` is deprecated and will be removed in future versions.
[TerminalIPythonApp] WARNING | You likely want to use `jupyter notebook` in the future
[I 14:03:47.947 NotebookApp] Serving notebooks from local directory: /Users/shyamalsuhanachandra/tensorflow/tensorflow/examples/udacity
[I 14:03:47.947 NotebookApp] 0 active kernels 
[I 14:03:47.947 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/
[I 14:03:47.947 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 14:03:52.472 NotebookApp] Kernel started: f3e77d2e-46d1-452c-b5e2-a9311499c411
[W 14:03:52.490 NotebookApp] 404 GET /nbextensions/widgets/notebook/js/extension.js?v=20161001140347 (::1) 7.14ms referer=http://localhost:8888/notebooks/1_notmnist.ipynb
/usr/local/opt/python/bin/python2.7: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed
[I 14:03:55.471 NotebookApp] KernelRestarter: restarting kernel (1/5)
/usr/local/opt/python/bin/python2.7: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed
[I 14:03:58.480 NotebookApp] KernelRestarter: restarting kernel (2/5)
/usr/local/opt/python/bin/python2.7: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed
[I 14:04:01.486 NotebookApp] KernelRestarter: restarting kernel (3/5)
/usr/local/opt/python/bin/python2.7: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed
[W 14:04:02.555 NotebookApp] Timeout waiting for kernel_info reply from f3e77d2e-46d1-452c-b5e2-a9311499c411
[I 14:04:04.494 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel f3e77d2e-46d1-452c-b5e2-a9311499c411 restarted
/usr/local/opt/python/bin/python2.7: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed
[W 14:04:07.502 NotebookApp] KernelRestarter: restart failed
[W 14:04:07.502 NotebookApp] Kernel f3e77d2e-46d1-452c-b5e2-a9311499c411 died, removing from map.
ERROR:root:kernel f3e77d2e-46d1-452c-b5e2-a9311499c411 restarted failed!
[W 14:04:07.514 NotebookApp] Kernel deleted before session
[W 14:04:07.514 NotebookApp] 410 DELETE /api/sessions/c20c97a9-4375-4b2a-a953-5094ad19f283 (::1) 1.73ms referer=http://localhost:8888/notebooks/1_notmnist.ipynb
[W 14:04:08.603 NotebookApp] Session not found: session_id=u'c20c97a9-4375-4b2a-a953-5094ad19f283'
[W 14:04:08.603 NotebookApp] 404 DELETE /api/sessions/c20c97a9-4375-4b2a-a953-5094ad19f283 (::1) 1.20ms referer=http://localhost:8888/notebooks/1_notmnist.ipynb
[I 14:04:08.622 NotebookApp] Kernel started: 175e72d8-349a-4786-b918-638502050d03
/usr/local/opt/python/bin/python2.7: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed
[I 14:04:11.624 NotebookApp] KernelRestarter: restarting kernel (1/5)
/usr/local/opt/python/bin/python2.7: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed
[I 14:04:14.632 NotebookApp] KernelRestarter: restarting kernel (2/5)
/usr/local/opt/python/bin/python2.7: No module named shutil_get_terminal_size; 'ipykernel' is a package and cannot be directly executed
takluyver commented 8 years ago

No module named shutil_get_terminal_size

It needs this module. Try:

# Upgrade pip
pip install --upgrade setuptools pip
# Install the backport
pip install backports.shutil_get_terminal_size
andyadamides commented 7 years ago

What about the second error "'ipykernel' is a package and cannot be directly executed" , have you managed to get a solution for this?

takluyver commented 7 years ago

That's a confusing error message that Python gives, but I think it's a consequence of whatever comes before it.

pjpjq commented 7 years ago

Same problem. Have you solved it?

sonsus commented 7 years ago

looks like you dont have ipykernel which manages usable kernels for jupyter. I think you should try installing a package "ipykernel" or if the jupyter client was damaged in someway, you should try install it from the scratch after deleting current one.

If you still want to fix it by doing it in hard way, that is manually installing jupyter kernel or locating it correctly, follow the lines below.

  1. check whether jupyter can recognize kernels installed in your computer $ source activate py27(or your py27 env name which has jupyter installed in it) $ jupyter-kernelspec list this will show you recognized kernels being used. e.g. Available kernels: python2 C:\Users\SEONIL\AppData\Roaming\jupyter\kernels\python2 python3 C:\Users\SEONIL\AppData\Local\conda\conda\envs\py35\share\jupyter\kernels\python3

if you see those output (kernel paths) but not working, go to the directories and double check they are there.

  1. if kernels are ok, check jupyter is locating the kernels correctly, then consider json file has some prob. path/to/your/jupyter/kernel.json

check the path in it. it contains kernel paths

  1. if they are ok, consider kernels are somehow damaged. Install those manually (few lines of commands) https://ipython.readthedocs.io/en/latest/install/kernel_install.html

  2. if installed but not working, check those kernels are located correctly again, and if wrong, move those to the proper directory jupyter is looking up (in step 1)

I dunno more elegant way but it worked for me! if there is better way to deal with it, pls comment it@!