Get RuntimeWarning when running Jupyter notebook and never connects to Kernel - python-3.x

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

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!

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!

jupyter-notebook for Anaconda for python3 :: kernel is crashing

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

mingw seems to crash python (Anaconda on windows)

I'm trying to install theano on a windows computer. When I do import theano python crashes. I think this is a mingw issue because when I uninstall mingw libpython and try to import theano, I get a theano warning, but python does not crash.
I have tried Anaconda 2.10 and 2.30. I follow the installation up with conda install mingw libpython, and then install the latest theano from github. import theano still crashes. Any ideas?
Here are the details of the "python.exe has stopped working" message:
Problem signature:
Problem Event Name: APPCRASH
Application Name: python.exe
Application Version: 0.0.0.0
Application Timestamp: 55678c56
Fault Module Name: lazylinker_ext.pyd
Fault Module Version: 0.0.0.0
Fault Module Timestamp: 55cdf48e
Exception Code: c000001d
Exception Offset: 000000000000517f
OS Version: 6.1.7600.2.0.0.768.3
Locale ID: 4105
Additional Information 1: 02b5
Additional Information 2: 02b5acdc9b8489c31d00cfe986aa8a42
Additional Information 3: fd67
Additional Information 4: fd674a72ea70861e63067edee1c9266b

Resources