Search code examples
jupyter-notebookminiconda

jupyter notebook kernel crashing non-stop


I have installed Jupyter Notebook through Conda. Been using it for a month without any issues. Suddenly today Jupyter Kernel started crashing and it is failing to restart. One point to note. This opens without any problems: http://localhost:8888/tree but crashes start to happen as soon as I open any notebook (.ipynb file)

(gpd) [arnuld@arch64 geo]$ jupyter-notebook

[I 13:01:24.389 NotebookApp] Serving notebooks from local directory:

/mnt/sda5/knuth/geo [I 13:01:24.389 NotebookApp] The Jupyter Notebook is running at:

[I 13:01:24.390 NotebookApp] http://localhost:8888/?token=d9ad51c90febcccc0b53d575c934396c4b28a65f307ef587

[I 13:01:24.390 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

[C 13:01:24.457 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time, to login with a token:

    http://localhost:8888/?token=d9ad51c90febcccc0b53d575c934396c4b28a65f307ef587

[I 13:01:24.832 NotebookApp] Accepting one-time-token-authenticated connection from ::1

[I 13:01:51.437 NotebookApp] Kernel started: a04e2381-690f-410f-a07b-ede5f843b462

Traceback (most recent call last):

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec)

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals)

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/site-packages/ipykernel_launcher.py", line 15, in from ipykernel import kernelapp as app

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/site-packages/ipykernel/init.py", line 2, in from .connect import *

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/site-packages/ipykernel/connect.py", line 13, in from IPython.core.profiledir import ProfileDir

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/site-packages/IPython/init.py", line 55, in from .terminal.embed import embed

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/site-packages/IPython/terminal/embed.py", line 17, in from IPython.terminal.ipapp import load_default_config

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/site-packages/IPython/terminal/ipapp.py", line 28, in from IPython.core.magics import (

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/site-packages/IPython/core/magics/init.py", line 18, in from .code import CodeMagics, MacroToEdit

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/site-packages/IPython/core/magics/code.py", line 23, in from urllib.request import urlopen

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/urllib/request.py", line 86, in import email

File "/mnt/sda5/knuth/geo/email.py", line 1, in import pandas as pd

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/site-packages/pandas/init.py", line 23, in from pandas.compat.numpy import *

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/site-packages/pandas/compat/init.py", line 63, in import http.client as httplib

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/http/client.py", line 71, in import email.parser

ModuleNotFoundError: No module named 'email.parser'; 'email' is not a package

[I 13:07:48.306 NotebookApp] KernelRestarter: restarting kernel (1/5), new random ports

Traceback (most recent call last):

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/runpy.py", line 193, in _run_module_as_main "main", mod_spec)

..... SNIPPED ......

File "/mnt/sda5/.miniconda3/envs/gpd/lib/python3.7/http/client.py", line 71, in import email.parser

ModuleNotFoundError: No module named 'email.parser'; 'email' is not a package

[W 13:08:00.373 NotebookApp] KernelRestarter: restart failed

[W 13:08:00.374 NotebookApp] Kernel 182b657e-54af-420d-bcdb-910da9391f37 died, removing from map.

[W13:08:45.530 NotebookApp] Timeout waiting for kernel_info reply from 182b657e-54af-420d-bcdb-910da9391f37

[E 13:08:45.533 NotebookApp] Error opening stream: HTTP 404: Not Found (Kernel does not exist: 182b657e-54af-420d-bcdb-910da9391f37)


Solution

  • > File "/mnt/sda5/knuth/geo/email.py", line 1, in

    This line told the problem.

    In my current working directory there is this file titled "email.py" which contains some code of mine. Since Jupyter Notebok was running from same directory, it thought it is from email-parser package and started looking for something it looks for only in a standard package.

    Two Lessons:

    • In Python, current working directory has highest priority, higher than even location of standard installation.

    • Never keep generic names for your files in the directory from where you are running Jupyter Notebook or Python else they will conflict with standard packages.

    Thanks to Min RK for solving this at gitter channel.