Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to run kernel #40

Closed
blarghmatey opened this issue Aug 17, 2015 · 42 comments
Closed

Unable to run kernel #40

blarghmatey opened this issue Aug 17, 2015 · 42 comments
Milestone

Comments

@blarghmatey
Copy link

When I try to open a notebook using the Python 3 kernel, I get the following output.

[I 12:29:22.834 NotebookApp] Kernel started: 5e226817-b874-4f6c-9573-be8bcc723690
/data/tmacey/.virtualenvs/data-analytics/bin/python: Error while finding spec for 'ipykernel.__main__' (<class 'ImportError'>: No module named 'logconfig'); 'ipykernel' is a package and cannot be directly executed
[I 12:29:25.834 NotebookApp] KernelRestarter: restarting kernel (1/5)
/data/tmacey/.virtualenvs/data-analytics/bin/python: Error while finding spec for 'ipykernel.__main__' (<class 'ImportError'>: No module named 'logconfig'); 'ipykernel' is a package and cannot be directly executed
[I 12:29:28.840 NotebookApp] KernelRestarter: restarting kernel (2/5)
/data/tmacey/.virtualenvs/data-analytics/bin/python: Error while finding spec for 'ipykernel.__main__' (<class 'ImportError'>: No module named 'logconfig'); 'ipykernel' is a package and cannot be directly executed
[I 12:29:31.843 NotebookApp] KernelRestarter: restarting kernel (3/5)
/data/tmacey/.virtualenvs/data-analytics/bin/python: Error while finding spec for 'ipykernel.__main__' (<class 'ImportError'>: No module named 'logconfig'); 'ipykernel' is a package and cannot be directly executed
[W 12:29:33.487 NotebookApp] Timeout waiting for kernel_info reply from 5e226817-b874-4f6c-9573-be8bcc723690
[I 12:29:34.846 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 5e226817-b874-4f6c-9573-be8bcc723690 restarted
/data/tmacey/.virtualenvs/data-analytics/bin/python: Error while finding spec for 'ipykernel.__main__' (<class 'ImportError'>: No module named 'logconfig'); 'ipykernel' is a package and cannot be directly executed
[W 12:29:37.852 NotebookApp] KernelRestarter: restart failed
[W 12:29:37.852 NotebookApp] Kernel 5e226817-b874-4f6c-9573-be8bcc723690 died, removing from map.
ERROR:root:kernel 5e226817-b874-4f6c-9573-be8bcc723690 restarted failed!
[W 12:29:37.863 NotebookApp] Kernel deleted before session
[W 12:29:37.864 NotebookApp] 410 DELETE /api/sessions/d8d3f8c2-1fdc-4d5d-b52d-07afb925587b (::1) 1.70ms referer=http://localhost:8888/notebooks/Untitled.ipynb

I am using IPython, Jupyter and ipykernel v4.0.3 with Python 3.4.3 on Linux.
Linux kommandcenter 4.1.5-1-MANJARO #1 SMP PREEMPT Tue Aug 11 05:14:23 UTC 2015 x86_64 GNU/Linux

@minrk
Copy link
Member

minrk commented Aug 17, 2015

logconfig is a bit weird, since that's not part of ipykernel or anything ipykernel imports, to my knowledge. Can you start notebooks in a different directory?

@yv
Copy link

yv commented Sep 6, 2015

I'm getting a similar thing without reference to logconfig:

[I 07:44:58.408 NotebookApp] Kernel started: a86335f9-0361-4f29-9acc-e9279ebcd84a
/usr/bin/python: cannot import name path; 'ipykernel' is a package and cannot be directly executed
[I 07:45:01.410 NotebookApp] KernelRestarter: restarting kernel (1/5)
/usr/bin/python: cannot import name path; 'ipykernel' is a package and cannot be directly executed
[I 07:45:04.420 NotebookApp] KernelRestarter: restarting kernel (2/5)
/usr/bin/python: cannot import name path; 'ipykernel' is a package and cannot be directly executed
[I 07:45:07.428 NotebookApp] KernelRestarter: restarting kernel (3/5)
/usr/bin/python: cannot import name path; 'ipykernel' is a package and cannot be directly executed
[W 07:45:08.492 NotebookApp] Timeout waiting for kernel_info reply from a86335f9-0361-4f29-9acc-e9279ebcd84a
[I 07:45:10.438 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel a86335f9-0361-4f29-9acc-e9279ebcd84a restarted
/usr/bin/python: cannot import name path; 'ipykernel' is a package and cannot be directly executed
[W 07:45:13.451 NotebookApp] KernelRestarter: restart failed
[W 07:45:13.451 NotebookApp] Kernel a86335f9-0361-4f29-9acc-e9279ebcd84a died, removing from map.

Update: mine seems to have been caused by an old system ipython package from Ubuntu and worked after removing all the old ipython/ipython-notebook packages and reinstalling them via pip

@sorrelh
Copy link

sorrelh commented Sep 24, 2015

I had the same problem after installing matplotlib. I had to uninstall both matplotlib and ipython/ipython notebooks, and reinstall with pip install "ipython[notebook]" --upgrade

@minrk
Copy link
Member

minrk commented Oct 5, 2015

@sorrelh what do you get from /usr/bin/python -V and /usr/bin/python -m pip list?

@minrk
Copy link
Member

minrk commented Oct 5, 2015

...and /usr/bin/python -m IPython --version

@eulerreich
Copy link

I ran into the same problem multiple times. It seems that it stems from the fact that I had ipython installed through both apt and pip.

@minrk minrk added this to the no action milestone Oct 9, 2015
@minrk
Copy link
Member

minrk commented Oct 9, 2015

Thanks, I think apt and setuptools frequently confuse each other. It's unfortunate how often this happens.

@minrk minrk closed this as completed Oct 9, 2015
@ghost
Copy link

ghost commented Nov 7, 2015

I am having the same problem. I installed Python 2.7 using Anaconda, and can run Jupyter notebook with no problems.

I just used Anaconda to make a new, concurrent, Python 3.5 installation along with Jupyter (I went through the correct procedure for maintaining the two versions of Python at once), and I receive an error when opening a notebook using the 3.5-kernel.

C:\Anaconda\envs\py35\python.exe: Error while finding spec for 'ipykernel.__main __' (<class 'ImportError'>: DLL load failed: The specified module could not be f ound.); 'ipykernel' is a package and cannot be directly executed

@WolfricWang
Copy link

I have the same issue now. Don't know how to solve..

@groakat
Copy link

groakat commented Jan 8, 2016

I have an io sub package in one of my projects. As soon as I created that folder ipython went crazy. I could fix it by renaming the package/folder

@eltonplima
Copy link

I have a similar problem, but in my case the import error is with decorator.

Is a new virtualenv instalation with python 3.4.3.

Any idea to solve this?

[I 04:13:00.279 NotebookApp] Kernel started: dd3938af-5112-4158-87b6-a93a41fdcc9a
/home/nanofix/repository/.sigmavenv/bin/python: Error while finding spec for 'ipykernel.main' (<class 'ImportError'>: cannot import name 'decorator'); 'ipykernel' is a package and cannot be directly executed
[I 04:13:03.282 NotebookApp] KernelRestarter: restarting kernel (1/5)
/home/nanofix/repository/.sigmavenv/bin/python: Error while finding spec for 'ipykernel.main' (<class 'ImportError'>: cannot import name 'decorator'); 'ipykernel' is a package and cannot be directly executed
[I 04:13:06.295 NotebookApp] KernelRestarter: restarting kernel (2/5)
/home/nanofix/repository/.sigmavenv/bin/python: Error while finding spec for 'ipykernel.main' (<class 'ImportError'>: cannot import name 'decorator'); 'ipykernel' is a package and cannot be directly executed
[I 04:13:09.317 NotebookApp] KernelRestarter: restarting kernel (3/5)
/home/nanofix/repository/.sigmavenv/bin/python: Error while finding spec for 'ipykernel.main' (<class 'ImportError'>: cannot import name 'decorator'); 'ipykernel' is a package and cannot be directly executed
[W 04:13:10.368 NotebookApp] Timeout waiting for kernel_info reply from dd3938af-5112-4158-87b6-a93a41fdcc9a
[I 04:13:12.329 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel dd3938af-5112-4158-87b6-a93a41fdcc9a restarted
/home/nanofix/repository/.sigmavenv/bin/python: Error while finding spec for 'ipykernel.main' (<class 'ImportError'>: cannot import name 'decorator'); 'ipykernel' is a package and cannot be directly executed
[W 04:13:15.348 NotebookApp] KernelRestarter: restart failed

@minrk
Copy link
Member

minrk commented Jan 11, 2016

@ellisonbg does pip install decorator solve it? What do you see in pip list?

@eltonplima
Copy link

I create a new virtualenv and reinstall. Now works!!!

@mwilbz
Copy link

mwilbz commented Jan 29, 2016

I had the same problem -- turned out it was because I had a file in the same folder written in Python 2 (when my ipython notebook was running Python 3). Changing the extension of that file to .txt fixed the issue for me.

@davidjb
Copy link

davidjb commented Mar 14, 2016

Seems I hit the same issue because I'd re-initialised a Python 2.7 virtualenv with Python 3.5. Starting from a clean virtualenv solved the issue.

@nebil
Copy link

nebil commented Mar 16, 2016

I had the same error, using Python v3.4.3 with Jupyter (v4.x) on Ubuntu GNU/Linux.
Error while finding spec for 'ipykernel.__main__' (<class 'ImportError'>: cannot import name 'decorator'); 'ipykernel' is a package and cannot be directly executed

I couldn't solve this problem, but then I noticed that, in the same folder I was running jupyter notebook, I had a file called decorator.py. Therefore, I renamed it to something else for avoiding name conflicts. And now it works. 😀

@szeitlin
Copy link

I'm having a similar problem after having to install with pip.
Error while finding spec for 'ipykernel.__main__' (<class 'ImportError'>: No module named 'path'

Unfortunately, pip doesn't know what I'm talking about when I ask it to install something called path.

If there are known issues with installing matplotlib etc. before ipython notebook, it would be great if someone would write those up with the recommended order of installation. I'd prefer to use anaconda, but in this case I don't have that option.

@takluyver
Copy link
Member

takluyver commented Mar 26, 2016 via email

@cranmer
Copy link

cranmer commented Apr 18, 2016

Hi, I'm having a similar problem with Jupyter 4.1.0. Specifically:
//anaconda/bin/python: cannot import name decorator; 'ipykernel' is a package and cannot be directly executed
I noticed @minrk comment:
Can you start notebooks in a different directory?
So I tired in a different directory and it is working without any (re)installation or upgrades. @minrk what did you suspect when you wrote that originally?

@minrk
Copy link
Member

minrk commented Apr 18, 2016

@cranmer a decorator.py file in the CWD (or any of many other module names that are imported) will prevent it from starting.

@dartdog
Copy link

dartdog commented Apr 24, 2016

Having the same issue I had installed new ipywidgets and then went into a spiral, did my best to nuke all prior installations since I've been using this stuff so long figured the upgrade combinations had finally hit me so I cleaned house and now I have Jupyter up and going via P3 and the p3 kernel is fine but my p2 kernel won't start. fwiw I did also uninstall and reinstall the ipywidgets and started to get errors on the nbextensions not being found (yet they are working) so far I'm not seeing the widgets, but that is a different issue.

I have verified that path.py is installed for p2..
given the above note from @minrk I tried starting the notebook in the next directory level down, same thing:

So anyhow I'm left with this when trying to start a P2 notebook:

 KernelRestarter: restarting kernel (3/5)
 /usr/bin/python2: No module named paths; 'ipykernel' is a package and cannot be directly executed

Grrrrr....

@takluyver
Copy link
Member

No module named paths

This message typically means it's finding an older version of the IPython package to import. If you have IPython installed through something like apt, you might want to uninstall that, and make sure that you have the latest version of IPython installed through pip.

@dartdog
Copy link

dartdog commented Apr 24, 2016

@takluyver Thanks for following me through this travale..I did remove the system installed Ipython via APT I also reinstalled using:

tom@tom-sam:~$ sudo python2 -m pip install ipykernel
tom@tom-sam:~$ sudo python2 -m ipykernel install
Installed kernelspec python2 in /usr/local/share/jupyter/kernels/python2

and that changed the error message for the p2 kernel to

/usr/bin/python2: No module named IPython.core.profiledir; 'ipykernel' is a package and cannot be directly executed

@takluyver
Copy link
Member

No module named IPython.core.profiledir

😕 Don't know about that one, sorry. I'd suggest trying to work out where it thinks it's importing IPython from - there might be a broken install lying around somewhere.

@dartdog
Copy link

dartdog commented Apr 24, 2016

somehow I seem to have broken ipython (2) quite completely, any ideas how to start over? If I even just try to start ipython from the command prompt I get:

tom@tom-sam:~$ ipython
Traceback (most recent call last):
File "/usr/local/bin/ipython", line 7, in <module>
from IPython import start_ipython

..... and at the end

    from .traitlets import *
   File "/usr/local/lib/python2.7/dist-packages/traitlets/traitlets.py", line 56, in <module>
   from ipython_genutils import py3compat
   ImportError: No module named ipython_genutils

And I have checked to see if they are installed via pip and they claim to be yet also if I start the interpeter i cannot import ipython (no such module)

Any ideas? where how to fix?

@takluyver
Copy link
Member

What's the shebang (#!...) in /usr/local/bin/ipython? WIth that Python, try running path/to/python -m pip list. Also, if you have $PYTHONPATH set, unset it.

@dartdog
Copy link

dartdog commented Apr 24, 2016

I have not directly accessed $PYTHONPATH (don't directly know how!)
The shebang line was:
tom@tom-sam:~$ /usr/bin/python -m pip list
gives me same as from main prompt and shows among the rest:

ipykernel (4.3.1)
ipython (4.2.0, /usr/local/lib/python2.7/dist-packages)

@dartdog
Copy link

dartdog commented Apr 24, 2016

is this an issue?

>>> import os
>>> os.environ['PYTHONPATH']
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/UserDict.py", line 23, in __getitem__
raise KeyError(key)
KeyError: 'PYTHONPATH'

@takluyver
Copy link
Member

No, that's fine, PYTHONPATH generally shouldn't be present unless you know you need it. I was checking that it wasn't set.

Does the list pip gives you also include ipython_genutils? If not, pip install that.

@dartdog
Copy link

dartdog commented Apr 24, 2016

Weird pip list did not show it I did pip install, it said requirement already satisfied, did pip unintsall, it did a bunch the reinstalled no pip list shows it. now Ipython starts from command line (improvement but new error message on Jupyter

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

So maybe install that?

@takluyver
Copy link
Member

Yup, install that...

I wonder if you have an old version of pip - try running:

pip install --upgrade setuptools pip

@dartdog
Copy link

dartdog commented Apr 25, 2016

Ok I'm almost there I ended up installing pip install jupyter, now the jupyter shebang in bin points at python (which is python 2) the remaining jupyter files in bin are set to p3 I did run pip3 install jupyter after the pip install, hoping that would fix what gets executed from the command line? it seems the whole mess related to confusion between the two installations? both p2 and p3 kernels are running but I'm back to errors in the console... which don't seem to be hurting but still....

@takluyver
Copy link
Member

You shouldn't need jupyter installed for both. The idea is that you install jupyter for one (preferably Python 3), and then just install ipykernel and its dependencies to provide the kernel for Python 2.

The jupyter command is provided by the package jupyter_core, so if you'd rather that pointed to Python 3, remove and reinstall that package with pip3.

@dartdog
Copy link

dartdog commented Apr 25, 2016

Well I was getting an error message from p2 start up complaining about other jupyter components after I fixed Jupyter-client which was why I went ahead with installing core... it "seems notebook running with p3 that is where the shebang for that points..

@takluyver
Copy link
Member

Rats, you're right, the jupyter_core package is required for ipykernel, but that creates the jupyter command, even when there's nothing for it to do.

@dartdog
Copy link

dartdog commented Apr 25, 2016

so... solution? and I guess open bug? not real sure what is running what given the mix of p2/p3 components in bin...

@takluyver
Copy link
Member

Opened jupyter/jupyter_core#76 about it. I don't think it should interfere with what you're trying to do, though. The notebook server should still be running on Python 3, it's just extra confusing.

@dartdog
Copy link

dartdog commented Apr 25, 2016

Thanks so much! whew! I suspect it may be involved with some of the other misc errors? but strange though.. for the time being, I'm good!

@yyf
Copy link

yyf commented Nov 14, 2016

Been having the same dead kernel issue when launching jupyter notebook. pip install "ipython[notebook]" --upgrade resolves my issue

@yusufghazi15
Copy link

How I fixed it!

I had made a custom package called io in the directory from where I was starting my Jupyter notebook. I removed that io package and the problem got resolved.

Check if you have any packages in the folder from where you are starting your jupyter notebook.

@ycsun19
Copy link

ycsun19 commented Apr 14, 2017

Having the same issue and still don't know how to fix yet.

I followed the steps here, Step 1 goes fine, but Step 2 gives an error:

/usr/bin/python3: Error while finding spec for 'ipykernel.__main__' (<class 'TypeError'>: __call__() missing 1 required positional argument: 'name'); 'ipykernel' is a package and cannot be directly executed

@Theresa24
Copy link

Hi all,

I kind of have the same problem when I try to start a root notebook with C++ kernel. The output I get is the following:

KernelRestarter: restarting kernel (2/5)
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python: No module named ROOT

I would be grateful for any kind of help!

Technologicat added a commit to Technologicat/spacemacs.d that referenced this issue Jun 25, 2019
… when using ipython3)

See (epc:pop-to-last-server-process-buffer) and ipython/ipykernel#40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests