jupyter-notebook for Anaconda for python3 :: kernel is crashing - python-3.x

I have Anaconda-2 and Anaconda-3 (meaning for Python2 and Python3, respectively) installed.
Here are the version outputs for each:
Current conda install:
platform : linux-64
conda version : 3.18.3
conda-build version : 1.18.1
python version : 3.4.3.final.0
requests version : 2.8.1
root environment : /home/jdoe/ANACONDA.d/v3.d (writable)
default environment : /home/jdoe/ANACONDA.d/v3.d
envs directories : /home/jdoe/ANACONDA.d/v3.d/envs
package cache : /home/jdoe/ANACONDA.d/v3.d/pkgs
channel URLs : https://repo.continuum.io/pkgs/free/linux-64/
https://repo.continuum.io/pkgs/free/noarch/
https://repo.continuum.io/pkgs/pro/linux-64/
https://repo.continuum.io/pkgs/pro/noarch/
config file : None
is foreign system : False
Current conda install:
platform : linux-64
conda version : 3.18.3
conda-build version : 1.18.1
python version : 2.7.10.final.0
requests version : 2.8.1
root environment : /home/jdoe/ANACONDA.d/v2.d (writable)
default environment : /home/jdoe/ANACONDA.d/v2.d
envs directories : /home/jdoe/ANACONDA.d/v2.d/envs
package cache : /home/jdoe/ANACONDA.d/v2.d/pkgs
channel URLs : https://repo.continuum.io/pkgs/free/linux-64/
https://repo.continuum.io/pkgs/free/noarch/
https://repo.continuum.io/pkgs/pro/linux-64/
https://repo.continuum.io/pkgs/pro/noarch/
config file : None
is foreign system : False
When I launch and use jupyter-notebook for Python-2, I have no problems. But, sadly, doing the same for Python-3, results in a repeatedly dying notebook (kernel crashes).
For completeness, I did update conda and anaconda (although they were pretty much the latest already):
jdoe$ conda3 update --prefix /home/jdoe/ANACONDA.d/v3.d conda
jdoe$ conda3 update --prefix /home/jdoe/ANACONDA.d/v3.d anaconda
jdoe$ conda2 update --prefix /home/jdoe/ANACONDA.d/v2.d conda
jdoe$ conda2 update --prefix /home/jdoe/ANACONDA.d/v2.d anaconda
Below is stdout output from the terminal in which I started the kernel (again Anaconda for Python-3).
Anyone know what might possibly be wrong?
Thank you. =:)
[I 15:24:43.388 NotebookApp] Serving notebooks from local directory: /home/jdoe
[I 15:24:43.388 NotebookApp] 0 active kernels
[I 15:24:43.388 NotebookApp] The IPython Notebook is running at: http://0.0.0.0:28888/
[I 15:24:43.388 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 15:25:02.182 NotebookApp] 302 GET / (65.209.47.35) 1.40ms
[W 15:25:27.872 NotebookApp] Notebook Google.Drives.d/xxx/CODE.DEV.d/JUPYTER.NOTEBOOKS.d/v3.d/Untitled.ipynb is not trusted
[I 15:25:27.969 NotebookApp] Kernel started: 2c3d6b64-cb0c-49be-bcdf-cc8aefe80afd
[I 15:25:30.969 NotebookApp] KernelRestarter: restarting kernel (1/5)
[W 15:25:38.209 NotebookApp] Timeout waiting for kernel_info reply from 2c3d6b64-cb0c-49be-bcdf-cc8aefe80afd
[I 15:25:39.973 NotebookApp] KernelRestarter: restarting kernel (1/5)
WARNING:root:kernel 2c3d6b64-cb0c-49be-bcdf-cc8aefe80afd restarted
[I 15:25:42.976 NotebookApp] KernelRestarter: restarting kernel (2/5)
WARNING:root:kernel 2c3d6b64-cb0c-49be-bcdf-cc8aefe80afd restarted
[I 15:25:45.979 NotebookApp] KernelRestarter: restarting kernel (3/5)
WARNING:root:kernel 2c3d6b64-cb0c-49be-bcdf-cc8aefe80afd restarted
[I 15:25:48.984 NotebookApp] KernelRestarter: restarting kernel (4/5)
WARNING:root:kernel 2c3d6b64-cb0c-49be-bcdf-cc8aefe80afd restarted
[W 15:25:51.989 NotebookApp] KernelRestarter: restart failed
[W 15:25:51.989 NotebookApp] Kernel 2c3d6b64-cb0c-49be-bcdf-cc8aefe80afd died, removing from map.
ERROR:root:kernel 2c3d6b64-cb0c-49be-bcdf-cc8aefe80afd restarted failed!
[W 15:25:52.033 NotebookApp] Kernel deleted before session

Related

Fixing jupyter notebook on AWS

I'm trying to set up jupyter notebook to run on AWS, I'm followed this guide - https://medium.com/#alexjsanchez/python-3-notebooks-on-aws-ec2-in-15-mostly-easy-steps-2ec5e662c6c6.
It worked but I now realise that every time I launch jupyter on my local machine, it asks for a password, also the password saved no longer works effectively locking me out of jupyter:
I presume its because I set up the ssh connection to port 8888 which is what jupyter uses by default. However, I've removed the ssh config file in step 10 but no change.
I'm stumped as to why jupyter no longer launches correctly, does anyone have any ideas on how I correct this?
I've also noticed that a token is given when launching jupyter from an EC2 instance
but in my case non is given
#Launching jupyter in notebook from EC2 enviornment
(base) [ec2-user#ip-172-31-59-151 ~]$ jupyter lab --no-browser
[I 14:49:49.917 LabApp] JupyterLab extension loaded from /home/ec2-user/anaconda3/lib/python3.8/site-packages/jupyterlab
[I 14:49:49.917 LabApp] JupyterLab application directory is /home/ec2-user/anaconda3/share/jupyter/lab
[I 14:49:49.919 LabApp] Serving notebooks from local directory: /home/ec2-user
[I 14:49:49.919 LabApp] Jupyter Notebook 6.1.4 is running at:
[I 14:49:49.919 LabApp] http://localhost:8888/
[I 14:49:49.920 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

jupyter notebook can't detect conda kernels only on boot

I'm trying to automatically start jupyter server on boot. (ec2, amazon linux)
I got the jupyter server working and correctly loading all the conda kernels.
and I tried to run jupyter on boot. (tried rc.local, systemd, crontab and all fails to load conda kernels and only loads basic python2 and python3 kernels)
I've traced it down to the nb_conda_kernels not finding being able to call 'conda' on boot, as below:
Oct 30 01:07:38 ip-172-31-17-102 rc.local: [E 01:07:38.816 NotebookApp] [nb_conda_kernels] couldn't call conda:
Oct 30 01:07:38 ip-172-31-17-102 rc.local: [Errno 2] No such file or directory: 'conda': 'conda'
Oct 30 01:07:38 ip-172-31-17-102 rc.local: [I 01:07:38.816 NotebookApp] [nb_conda_kernels] enabled, 0 kernels found
Oct 30 01:07:39 ip-172-31-17-102 rc.local: [I 01:07:39.645 NotebookApp] Loading IPython parallel extension
Oct 30 01:07:39 ip-172-31-17-102 rc.local: [I 01:07:39.701 NotebookApp] JupyterLab extension loaded from /home/ec2-user/anaconda3/lib/python3.7/site-packages/jupyterlab
Oct 30 01:07:39 ip-172-31-17-102 rc.local: [I 01:07:39.702 NotebookApp] JupyterLab application directory is /home/ec2-user/anaconda3/share/jupyter/lab
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] [nb_conda] enabled
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] Serving notebooks from local directory: /home/ec2-user/browse
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] The Jupyter Notebook is running at:
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] http://172.31.17.102:8888/
Oct 30 01:07:40 ip-172-31-17-102 rc.local: [I 01:07:40.061 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
The weirdest thing is that when I kill the running server with "sudo ss --tulpn | grep 8888" (to find pid for jupyter notebook which is listening on port 8888) and "sudo kill -9 {pid}" (to kill the process. checked that I killed it successfully), and I restart the server via the same command used in boot, then jupyter successfully loads the conda kernels, as below:
[I 01:12:51.369 NotebookApp] [nb_conda_kernels] enabled, 22 kernels found
[I 01:12:51.612 NotebookApp] Loading IPython parallel extension
[I 01:12:51.641 NotebookApp] JupyterLab extension loaded from /home/ec2-user/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 01:12:51.641 NotebookApp] JupyterLab application directory is /home/ec2-user/anaconda3/share/jupyter/lab
[I 01:12:51.791 NotebookApp] [nb_conda] enabled
[I 01:12:51.792 NotebookApp] Serving notebooks from local directory: /home/ec2-user/browse
[I 01:12:51.792 NotebookApp] The Jupyter Notebook is running at:
[I 01:12:51.792 NotebookApp] http://172.31.17.102:8888/
[I 01:12:51.792 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
I've seen one particular question on stackoverflow about this issue. (Jupyter notebook can't find kernel when run through /etc/rc.local)
but the issue here is that when I type "jupyter kernelspec list", I only get python3 and python2, even when jupyter has already loaded conda kernels successfully.
python3 /home/ec2-user/anaconda3/share/jupyter/kernels/python3
python2 /usr/share/jupyter/kernels/python2
Also, I've tried changing environmentspecmanager in jupyter config file to see if it solves the issue but it didn't. (same error log, "couldn't call conda")
what is the problem here?
conda has not been configured yet when rc.local is executed. This is usually done through the .bashrc file. But you can try to just add it to the rc.local script (before launching jupyter):
source /home/ec2-user/anaconda3/etc/profile.d/conda.sh
This should set up the use of conda
Thank you, FlyterTeller. I used the code below in rc.local instead of the one you showed.
if [ -f "/home/ec2-user/anaconda3/etc/profile.d/conda.sh" ]; then
. "/home/ec2-user/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false /home/ec2-user/anaconda3/bin/jupyter notebook --config /home/ec2-user/.jupyter/jupyter_notebook_config.py --allow-root --no-browser
fi
But you were right about conda being not configured when rc.local is executed. Thanks for nudging me in the right direction, so i'm upvoting and accepting your answer!

How to Update the Installed Widgets

When I started Jupyter Lab from the cmd prompt within a python virtual environment folder, I noticed the Jupyter startup process display that
three of the Jupyter widgets are outdated. There was no display message describing how to update these widgets.
Therefore, the question is: How to update the Jupyter widgets?
I searched for a solution and did not find any.
The Startup code w/ three widget outdated messages at bottom
(ML3-2Gxa7Dh2) C:\pythonVE\ML3>jupyter lab
[I 11:26:05.773 LabApp] JupyterLab extension loaded from c:\python37\lib\site-packages\jupyterlab
[I 11:26:05.773 LabApp] JupyterLab application directory is c:\python37\share\jupyter\lab
[W 11:26:05.793 LabApp] Error loading server extension jupyterlab_latex
Traceback (most recent call last):
File "c:\python37\lib\site-packages\notebook\notebookapp.py", line 1572, in init_server_extensions
mod = importlib.import_module(modulename)
File "c:\python37\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'jupyterlab_latex'
[W 11:26:05.840 LabApp] JupyterLab server extension not enabled, manually loading...
[I 11:26:05.881 LabApp] JupyterLab extension loaded from c:\python37\lib\site-packages\jupyterlab
[I 11:26:05.881 LabApp] JupyterLab application directory is c:\python37\share\jupyter\lab
[I 11:26:05.883 LabApp] Serving notebooks from local directory: C:\pythonVE\ML3
[I 11:26:05.883 LabApp] The Jupyter Notebook is running at:
[I 11:26:05.883 LabApp] http://localhost:8888/
[I 11:26:05.884 LabApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 11:26:07.540 LabApp] 302 GET /lab (::1) 1.00ms
[I 11:26:16.232 LabApp] 302 POST /login?next=%2Flab (::1) 1.00ms
[W 11:26:47.607 LabApp] The extension "#jupyter-widgets/jupyterlab-manager" is outdated.
[W 11:26:47.609 LabApp] The extension "#jupyterlab/latex" is outdated.
[W 11:26:47.611 LabApp] The extension "#jupyterlab/toc" is outdated.
[I 11:26:48.411 LabApp] Build is up to date
|[I 11:26:54.426 LabApp] Kernel started: 5ba63189-6fa9-40cc-87ea-eea2d869
Widgets seem to work within the Jlab notebook.
I had a similar problem which I could solve by typing the following command:
jupyter labextension update --all
With
jupyter labextension list
I could show me the extension including those that were outdated and the command to update them was shown there, too.
Since you're writing “cmd prompt” I expect you are using Windows, so maybe your results may vary. Because I'm unsing Linux and cannot test it on Windows, I don't know if npm behaves the same.
BTW: With
jupyter labextension --help
you can get further help on labextensions including the hint on “install” which might be interesting for you, too, because your output also complains about a missing LaTeX extension.

Get RuntimeWarning when running Jupyter notebook and never connects to Kernel

I have a fresh install of python 3.7.2 and pip installed jupyter 4.4.0 in a fresh venv on Windows 7.0 professional.
I started a Jupyter notebook and my notebook never connects to the kernel.
On the command prompt, I see this error:
[I 17:41:11.959 NotebookApp] Kernel started: 35b03148-7d3e-48cb-a270-ebe959012d98
[I 17:41:14.307 NotebookApp] Adapting to protocol v5.1 for kernel 35b03148-7d3e-48cb-a270-ebe959012d98
<full path masked>...\py372venv\lib\site-packages\notebook\base\zmqhandlers.py:284: RuntimeWarning: coroutine 'WebSocketHandler.get' was never awaited
super(AuthenticatedZMQStreamHandler, self).get(*args, **kwargs)
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
[W 17:41:15.404 NotebookApp] Replacing stale connection: 35b03148-7d3e-48cb-a270-ebe959012d98:3b9a037fced84ccc891192e2f387bae0
[W 17:41:37.415 NotebookApp] Replacing stale connection: 35b03148-7d3e-48cb-a270-ebe959012d98:3b9a037fced84ccc891192e2f387bae0
[W 17:42:01.421 NotebookApp] Replacing stale connection: 35b03148-7d3e-48cb-a270-ebe959012d98:3b9a037fced84ccc891192e2f387bae0
[W 17:42:29.468 NotebookApp] Replacing stale connection: 35b03148-7d3e-48cb-a270-ebe959012d98:3b9a037fced84ccc891192e2f387bae0
[W 17:43:05.489 NotebookApp] Replacing stale connection: 35b03148-7d3e-48cb-a270-ebe959012d98:3b9a037fced84ccc891192e2f387bae0
These replacing stale connection messages continue.
What could be the issue? I am new to Jupyter and a bit less new to Python.
Try to downgrade tornado version (pip install 'tornado<6'), as described there: https://github.com/jupyter/notebook/issues/4437#issuecomment-468758440
For me, downgrading from 6.0.1 to 5.1.1 solved the issue with jupyter not connecting to kernel.
install 5.1.1 version and try.
pip.exe" show tornado
Name: tornado
**Version: 5.1.1**
Summary: Tornado is a Python web framework and asynchronous networking library, originally developed at FriendFeed.
Home-page: http://www.tornadoweb.org/
Author: Facebook
Author-email: python-tornado#googlegroups.com
License: http://www.apache.org/licenses/LICENSE-2.0
Location: c:\users\<userid>\path\to\site-packages
Requires:
Required-by: jupyterhub, notebook, jupyter-client, ipykernel, distributed, bokeh, anaconda-project

Run screen jupyter notebook in a conda environment

I am trying to run jupyter notebook from a server through a ssh tunnel in a screen window with
screen jupyter notebook --no-browser --port=8888
It works, but I am not able to let it run in a conda environment I have created.
I tried creating a screen where I activate the environment and then call the notebook:
source activate env37 -->(meaning python 3.7)
(env37) user#server:~$ jupyter notebook --no-browser --port 8889
[I 07:24:11.610 NotebookApp] [nb_conda_kernels] enabled, 4 kernels found
[I 07:24:12.242 NotebookApp] [nb_anacondacloud] enabled
[I 07:24:12.297 NotebookApp] ✓ nbpresent HTML export ENABLED
But it didn't work, since in the notebook I see this:
3.5.4 |Anaconda custom (64-bit)| (default, Nov 20 2017, 18:44:38)
--> Python is 3.5.
Other ideas?
Thanks
I suppose you should change the ipython/notebook kernel rather than changing the environment check this answer. I hope that solves your problem!

Resources