jupyter notebook kernel crashing non-stop - jupyter-notebook

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)

> 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.

Related

jupyter notebook list error after drive ran out of room

another user on my ubuntu server was trying to install anaconda in their home directory. they downloaded anaconda to their home directory and installed it, and it took up all remaining room for users on the server. So my user who is a different user, in a different home directory could no longer run jupyter notebook and I got a dead kernel error. After moving their copy of anaconda from the their home directory to a different drive with more room, I am now able to again launch and run jupyter notebooks with my user, but I'm now getting the error below when I try to check for running notebook servers and get the token. Does anyone know what the issue might be and can you suggest how to fix? Again this was another user installing anaconda in their home directory. I'm confused why that would effect my user with a completely different home directory, except that we ran out of room on the drive momentarily.
code:
jupyter notebook list
error:
Traceback (most recent call last):
File "/home/user/anaconda3/bin/jupyter-notebook", line 11, in <module>
sys.exit(main())
File "/home/user/anaconda3/lib/python3.7/site-packages/jupyter_core/application.py", line 254, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/home/user/anaconda3/lib/python3.7/site-packages/traitlets/config/application.py", line 845, in launch_instance
app.start()
File "/home/user/anaconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 2288, in start
super().start()
File "/home/user/anaconda3/lib/python3.7/site-packages/jupyter_core/application.py", line 243, in start
self.subapp.start()
File "/home/user/anaconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 596, in start
serverinfo_list = list(list_running_servers(self.runtime_dir))
File "/home/user/anaconda3/lib/python3.7/site-packages/notebook/notebookapp.py", line 2388, in list_running_servers
info = json.load(f)
File "/home/user/anaconda3/lib/python3.7/json/__init__.py", line 296, in load
parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
File "/home/user/anaconda3/lib/python3.7/json/__init__.py", line 348, in loads
return _default_decoder.decode(s)
File "/home/user/anaconda3/lib/python3.7/json/decoder.py", line 337, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/home/user/anaconda3/lib/python3.7/json/decoder.py", line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
I was able to solve the issue by going to the directory
/home/user/.local/share/jupyter/runtime
and deleting files with names like
nbserver-xxxx.json
that were empty. After that jupyter notebook list worked fine.

Getting following error while runnin juptyer notebook from ananconda prompt

Please let me know the solution to fix it as didn't find much on google.
Faced this error while trying to start jupyter notebook from anaconda.
But can open it from cmd.
Environment variables of anaconda are properly configured.
Traceback (most recent call last):
File "C:\Users\Ankit Chawrai\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\notebook\notebookapp.py", line 51, in <module>
from zmq.eventloop import ioloop
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\zmq\__init__.py", line 50, in <module>
from zmq import backend
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\Users\Ankit Chawrai\anaconda3\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: DLL load failed while importing error: The specified module could not be found.```
I always launch Jupyter Notebooks from either from the Windows menu or the Anaconda Navigator. Almost always from the Windows Start Menu.
When I installed Anaconda a shortcut was created within the Start Menu, and when clicked it launches a cmd window, runs some scripts and then opens the Jupyter Explorer page within my default browser.

Jupyter Notebook virtual environment kernel broken: "ImportError: DLL load failed: The specified module could not be found."

I recently modified my conda virtual environment to try installing a package (openjpeg) because of issues I was running into with pydicom. I restarted my Jupyter Notebook, but then it seemed something I did completely messed up my ability to load the environment in Jupyter Notebook. I tried recreating the environment from scratch and manually installing my needed packages, but got the same error. After I load jupyter notebook from command line and open my .ipynb file using the environment kernel, I get the error copied below in the cmd/miniconda window:
[I 00:22:55.851 NotebookApp] KernelRestarter: restarting kernel (4/5), new random ports
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\envs\Py36Base\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "C:\ProgramData\Anaconda3\envs\Py36Base\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\ProgramData\Anaconda3\envs\Py36Base\lib\site-packages\ipykernel_launcher.py", line 15, in <module>
from ipykernel import kernelapp as app
File "C:\ProgramData\Anaconda3\envs\Py36Base\lib\site-packages\ipykernel\__init__.py", line 2, in <module>
from .connect import *
File "C:\ProgramData\Anaconda3\envs\Py36Base\lib\site-packages\ipykernel\connect.py", line 18, in <module>
import jupyter_client
File "C:\ProgramData\Anaconda3\envs\Py36Base\lib\site-packages\jupyter_client\__init__.py", line 4, in <module>
from .connect import *
File "C:\ProgramData\Anaconda3\envs\Py36Base\lib\site-packages\jupyter_client\connect.py", line 21, in <module>
import zmq
File "C:\ProgramData\Anaconda3\envs\Py36Base\lib\site-packages\zmq\__init__.py", line 55, in <module>
from zmq import backend
File "C:\ProgramData\Anaconda3\envs\Py36Base\lib\site-packages\zmq\backend\__init__.py", line 40, in <module>
reraise(*exc_info)
File "C:\ProgramData\Anaconda3\envs\Py36Base\lib\site-packages\zmq\utils\sixcerpt.py", line 34, in reraise
raise value
File "C:\ProgramData\Anaconda3\envs\Py36Base\lib\site-packages\zmq\backend\__init__.py", line 27, in <module>
_ns = select_backend(first)
File "C:\ProgramData\Anaconda3\envs\Py36Base\lib\site-packages\zmq\backend\select.py", line 28, in select_backend
mod = __import__(name, fromlist=public_api)
File "C:\ProgramData\Anaconda3\envs\Py36Base\lib\site-packages\zmq\backend\cython\__init__.py", line 6, in <module>
from . import (constants, error, message, context,
ImportError: DLL load failed: The specified module could not be found.
[W 00:22:58.870 NotebookApp] KernelRestarter: restart failed
[W 00:22:58.870 NotebookApp] Kernel 30d40c82-f840-47cc-8192-54aeb028d1aa died, removing from map.
Any thoughts on what I can do to fix this? I saw some posts with similar errors (but different issue overall) and the most comomon solution was making sure the Anaconda system environment PATH variable is set (which it is). For the record I'm running Windows 10 and latest Anaconda install (first environment using Python 3.8, re-built environment using Python 3.6). If you think I should copy my conda list output for the virtual environment let me know
It seems a rather simple fix was to activate the environment and then run jupyter notebook. That seemed to stop the error. Was not aware this was a requirement?

Jupyter - how to run and install?

I need to install jupyter notebook on two computers (both Linux Mint 19.2 Tina).
On one computer I have installed it and run
jupyter notebook
I can't run the cell. I click to run and nothing happens. What does not connected mean?
On the second computer I run
jupyter notebook
and there is an error:
Traceback (most recent call last):
File "/home/linux/.local/bin/jupyter-notebook", line 5, in <module>
from notebook.notebookapp import main
File "/home/linux/.local/lib/python2.7/site-packages/notebook/__init__.py", line 25, in <module>
from .nbextensions import install_nbextension
File "/home/linux/.local/lib/python2.7/site-packages/notebook/nbextensions.py", line 31, in <module>
from .config_manager import BaseJSONConfigManager
File "/home/linux/.local/lib/python2.7/site-packages/notebook/config_manager.py", line 15, in <module>
from traitlets.config import LoggingConfigurable
File "/home/linux/.local/lib/python2.7/site-packages/traitlets/__init__.py", line 1, in <module>
from .traitlets import *
File "/home/linux/.local/lib/python2.7/site-packages/traitlets/traitlets.py", line 49, in <module>
import enum
ImportError: No module named enum
I tried to install it
pip install --user pip enum34
pip install --upgrade pip enum34
but it didn't help. Is it only for python3?
EDIT
Another problem: there is no python2 python3 in the notebook options.
Terminal:
jupyter notebook
[I 13:08:08.694 NotebookApp] Serving notebooks from local directory: /media/linux/DATADISK/venv
[I 13:08:08.694 NotebookApp] The Jupyter Notebook is running at:
[I 13:08:08.694 NotebookApp] http://localhost:8888/?token=7344956fea0cbfc5eaab06066d8503fa35ba999123e5908c
[I 13:08:08.694 NotebookApp] or http://127.0.0.1:8888/?token=7344956fea0cbfc5eaab06066d8503fa35ba999123e5908c
[I 13:08:08.694 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 13:08:08.697 NotebookApp]
To access the notebook, open this file in a browser:
file:///home/linux/.local/share/jupyter/runtime/nbserver-12847-open.html
Or copy and paste one of these URLs:
http://localhost:8888/?token=7344956fea0cbfc5eaab06066d8503fa35ba999123e5908c
or http://127.0.0.1:8888/?token=7344956fea0cbfc5eaab06066d8503fa35ba999123e5908c
ERROR:
python3 -m ipykernel install --user
Traceback (most recent call last):
File "/usr/lib/python3.6/runpy.py", line 183, in _run_module_as_main
mod_name, mod_spec, code = _get_module_details(mod_name, _Error)
File "/usr/lib/python3.6/runpy.py", line 142, in _get_module_details
return _get_module_details(pkg_main_name, error)
File "/usr/lib/python3.6/runpy.py", line 109, in _get_module_details
__import__(pkg_name)
File "/home/linux/.local/lib/python3.6/site-packages/ipykernel/__init__.py", line 2, in <module>
from .connect import *
File "/home/linux/.local/lib/python3.6/site-packages/ipykernel/connect.py", line 13, in <module>
from IPython.core.profiledir import ProfileDir
File "/usr/lib/python3/dist-packages/IPython/__init__.py", line 49, in <module>
from .terminal.embed import embed
File "/usr/lib/python3/dist-packages/IPython/terminal/embed.py", line 18, in <module>
from IPython.terminal.interactiveshell import TerminalInteractiveShell
File "/usr/lib/python3/dist-packages/IPython/terminal/interactiveshell.py", line 20, in <module>
from prompt_toolkit.shortcuts import create_prompt_application, create_eventloop, create_prompt_layout, create_output
ImportError: cannot import name 'create_prompt_application'
Try a fresh start with Jupiter in a new environment.
Note: If you are using python 2.7 you need to make sure venv is installed. A

Jupyter Notebook only opens on base environment (Python 3.7, Windows 10)

I'm not sure what changed but similarly to this post:
Jupyter notebook only works in base environment
Jupyter notebook only opens when I activate my base environment, ie:
C:\Users\user\activate base
(base) C:\Users\user\jupyter notebook
This happens on powershell, cmd, and cmder. In the default, unspecified environment, I get this error:
C:\Users\user>jupyter notebook
Traceback (most recent call last):
File "C:\Users\user\anaconda3\Scripts\jupyter-notebook-script.py", line 6, in <module>
from notebook.notebookapp import main
File "C:\Users\user\anaconda3\lib\site-packages\notebook\notebookapp.py", line 62, in <module>
from tornado import httpserver
File "C:\Users\user\anaconda3\lib\site-packages\tornado\httpserver.py", line 29, in <module>
import ssl
File "C:\Users\user\anaconda3\lib\ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: DLL load failed: The specified procedure could not be found.
In the default environment, I can call pip commands but I get this error. It seems to be related to my first issue above.
C:\Users\user>pip install
Could not fetch URL https://pypi.org/simple/pip/: There was a problem
confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org',
port=443): Max retries exceeded with url: /simple/pip/ (Caused by
SSLError("Can't connect to HTTPS URL because the SSL module is not
available.")) - skipping

Resources