Error connecting jupyter notebook 5.0 in root environment - jupyter-notebook

I've been using jupyter notebook in my root environment and a few other environment for several months. Upgraded to jupyter notebook 5 last week and it worked well until yesterday.
Yesterday - computer froze. After restarting, jupyter notebook gives an error (2x) when launched from root environment:
(some info replaced with # below)
[I 08:57:31.223 NotebookApp] Serving notebooks from local directory: #######
[I 08:57:31.223 NotebookApp] 0 active kernels
[I 08:57:31.223 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=########################
[I 08:57:31.223 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 08:57:31.224 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=########################
[I 08:57:32.992 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[I 08:58:01.367 NotebookApp] Kernel started: ###########
[I 08:58:02.775 NotebookApp] Adapting to protocol v5.1 for kernel ############
[IPKernelApp] ERROR | No such comm target registered: jupyter.widget.version
[IPKernelApp] ERROR | No such comm target registered: jupyter.widget.version
I've tried copying and pasting the link provided above. It removed one of the error messages next time it was launched, then 2 error messages after trying to launch again.
Jupyter notebook works when launched from a different conda environment.
Any thoughts on how to get this working in my root environment again?

Related

Slow Connection to Jupyter Notebook on WSL2

I'm having a weird problem with Jupyter notebook running inside a WSL2 instance. Every time I start a new notebook, my first connection to localhost:8888 (or localhost:XXXX for any other port number) takes a LONG time to connect, like 5-10 minutes. Once one connection to that port has been made, however, all subsequent connections happen at a normal speed. As far as I can tell the delay is not specifically happening within the Jupyter server, as the server output doesn't show any GET requests during the waiting period:
> jupyter notebook .
[I 08:29:21.282 NotebookApp] Authentication of /metrics is OFF, since other authentication is disabled.
[W 08:29:21.729 NotebookApp] All authentication is disabled. Anyone who can connect to this server will be able to run code.
[I 08:29:21.732 NotebookApp] Serving notebooks from local directory: /home/peter/jade_poplar/code/python
[I 08:29:21.732 NotebookApp] Jupyter Notebook 6.4.0 is running at:
[I 08:29:21.732 NotebookApp] http://localhost:8888/
[I 08:29:21.732 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
...
5-10 MINUTES ELAPSE
...
[I 08:38:12.718 NotebookApp] 302 GET / (127.0.0.1) 2.110000ms
However, the issue does appear to be limited only to Jupyter: if I just listen on the port with nc -l 8888 and then point my browser to localhost:8888 the GET request shows up immediately.
I have tried random fixes to other problems that I found on SE, eg. this one, but to no avail. Any advice, or even a suggestion as to where to start looking, would be greatly appreciated! This is driving me bonkers, although I am getting a lot of chess in while I wait for my notebooks to load :D
Old answer
I found 2 ways to get around the "waiting time" on my system.
Hit Ctrl+C once after the console output hangs at Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Set the DISPLAY environment variable to nothing: DISPLAY= jupyter notebook .. Apparently, the same trick works for pip.
UPDATE 1
After some debugging I figured out, that the --no-browser option does the trick as well:
jupyter notebook --no-browser .
jupyter-notebook by default opens localhost:8888 in the browser.
I assume WSL2 has problems opening the default browser, and therefore times out.
UPDATE 2
To confirm my guess, from UPDATE 1, I set up WSL to be able to open a browser window:
Installing firfox in WSL (ubuntu):
sudo apt install firefox
Setting up X11 forwarding on WSL2
Using this setup jupyter-notebook starts normally and localhost:8888 is opened in firefox.

Jupyter notebook show error: Exception while loading config file

I open Anaconda and then open Jupyter notebook (6.1.4).
http://localhost:8903/tree is opened
However, when I click New Python3 a blank page with below address opened. It keep spinning, look like trying to open the python3
http://localhost:8959/notebooks/Untitled21.ipynb?kernel_name=python3
Also a notice box "Application Launch error" appear with following text
Can anyone help, please?
Thanks
HHC
[E 10:40:06.955 NotebookApp] Exception while loading config file C:\Users\HPNEW\.jupyter\jupyter_notebook_config.py
Traceback (most recent call last):
File "C:\Users\HPNEW\anaconda3\lib\site-packages\traitlets\config\application.py", line 737, in _load_config_files
config = loader.load_config()
File "C:\Users\HPNEW\anaconda3\lib\site-packages\traitlets\config\loader.py", line 616, in load_config
self._read_file_as_dict()
File "C:\Users\HPNEW\anaconda3\lib\site-packages\traitlets\config\loader.py", line 648, in _read_file_as_dict
exec(compile(f.read(), conf_filename, 'exec'), namespace, namespace)
File "C:\Users\HPNEW\.jupyter\jupyter_notebook_config.py", line 149
c.NotebookApp.browser = u'C:/Program Files/Mozilla Firefox/firefox.exe %s'
^
IndentationError: unexpected indent
[I 10:40:07.629 NotebookApp] The port 8888 is already in use, trying another port.
[I 10:40:07.630 NotebookApp] The port 8889 is already in use, trying another port.
[I 10:40:07.630 NotebookApp] The port 8890 is already in use, trying another port.
[I 10:40:07.631 NotebookApp] The port 8891 is already in use, trying another port.
[I 10:40:07.631 NotebookApp] The port 8892 is already in use, trying another port.
[I 10:40:07.890 NotebookApp] JupyterLab extension loaded from C:\Users\HPNEW\anaconda3\lib\site-packages\jupyterlab
[I 10:40:07.891 NotebookApp] JupyterLab application directory is C:\Users\HPNEW\anaconda3\share\jupyter\lab
[I 10:40:07.898 NotebookApp] Serving notebooks from local directory: C:\Users\HPNEW
[I 10:40:07.898 NotebookApp] Jupyter Notebook 6.1.4 is running at:
[I 10:40:07.898 NotebookApp] http://localhost:8959/?token=042d81d0eafc2db7d720a15adc7a5815bec1dedf42d6b248
[I 10:40:07.899 NotebookApp] or http://127.0.0.1:8959/?token=042d81d0eafc2db7d720a15adc7a5815bec1dedf42d6b248
[I 10:40:07.899 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 10:40:07.969 NotebookApp]
To access the notebook, open this file in a browser:
file:///C:/Users/HPNEW/AppData/Roaming/jupyter/runtime/nbserver-13804-open.html
Or copy and paste one of these URLs:
http://localhost:8959/?token=042d81d0eafc2db7d720a15adc7a5815bec1dedf42d6b248
or http://127.0.0.1:8959/?token=042d81d0eafc2db7d720a15adc7a5815bec1dedf42d6b248

Jupyter Notebook Not Showing Output

I have using jupyter notebook for past few months. I am facing this type of problem for the first time.
Exact Problem : When I run a cell on jupyter notebook it is running for long time, but not showing any output.
Solution that I have already tried based on some google searches:
1. Uninstalled anaconda and reinstalled it.
2. Updated conda
3. Updated ipykernel
4. Download and installed microsoft visual c++ 2015 redistribute update 3
5. Restarted kernel and tried again
6. Shutdown files in running tab
7. And so on.
Properties:
1. Windows 10 Pro
2. Python : Python 3.6.7
3. Jupyter :-
jupyter core : 4.6.3
jupyter-notebook : 6.1.1
qtconsole : 4.7.5
ipython : 7.16.1
ipykernel : 5.3.4
jupyter client : 6.1.6
jupyter lab : not installed
nbconvert : 5.6.1
ipywidgets : 7.5.1
nbformat : 5.0.7
traitlets : 4.3.3
4. Anaconda 3 - 64 bit
Error showing in jupyter notebook prompt:
[I 21:24:04.349 NotebookApp] JupyterLab extension loaded from C:\Users\Mathesh\Anaconda3\lib\site-packages\jupyterlab
[I 21:24:04.349 NotebookApp] JupyterLab application directory is C:\Users\Mathesh\Anaconda3\share\jupyter\lab
[I 21:24:04.411 NotebookApp] Serving notebooks from local directory: C:\Users\Mathesh
[I 21:24:04.411 NotebookApp] The Jupyter Notebook is running at:
[I 21:24:04.418 NotebookApp] http://localhost:8888/?token=8e7be14b316ad1fd7bfb00fe144e3a98ea7655979b6d18dd
[I 21:24:04.418 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 21:24:04.555 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=8e7be14b316ad1fd7bfb00fe144e3a98ea7655979b6d18dd
[I 21:24:15.956 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[I 21:24:47.204 NotebookApp] Kernel started: f321d571-c5dc-41c0-867e-6e69da753793
[I 21:25:07.344 NotebookApp] Starting buffering for f321d571-c5dc-41c0-867e-6e69da753793:2828c21d9fb2439fb9aa4251d66f845a
[I 21:25:08.333 NotebookApp] Restoring connection for f321d571-c5dc-41c0-867e-6e69da753793:2828c21d9fb2439fb9aa4251d66f845a
[W 21:26:38.362 NotebookApp] WebSocket ping timeout after 90013 ms.
[I 21:26:43.385 NotebookApp] Starting buffering for f321d571-c5dc-41c0-867e-6e69da753793:2828c21d9fb2439fb9aa4251d66f845a
[I 21:26:44.458 NotebookApp] Restoring connection for f321d571-c5dc-41c0-867e-6e69da753793:2828c21d9fb2439fb9aa4251d66f845a
[I 21:26:45.506 NotebookApp] Saving file at /Desktop/Testing_Sample.ipynb
[I 21:27:35.723 NotebookApp] Kernel restarted: f321d571-c5dc-41c0-867e-6e69da753793
[I 21:27:45.719 NotebookApp] Starting buffering for f321d571-c5dc-41c0-867e-6e69da753793:2828c21d9fb2439fb9aa4251d66f845a
[I 21:27:45.860 NotebookApp] Saving file at /Desktop/Testing_Sample.ipynb
[I 21:27:53.886 NotebookApp] Kernel shutdown: f321d571-c5dc-41c0-867e-6e69da753793
[W 21:27:53.891 NotebookApp] 404 POST /api/kernels/f321d571-c5dc-41c0-867e-6e69da753793/restart (::1): Kernel does not exist: f321d571-c5dc-41c0-867e-6e69da753793
[W 21:27:53.892 NotebookApp] Kernel does not exist: f321d571-c5dc-41c0-867e-6e69da753793
[W 21:27:53.892 NotebookApp] 404 POST /api/kernels/f321d571-c5dc-41c0-867e-6e69da753793/restart (::1) 19414.84ms referer=http://localhost:8888/notebooks/Desktop/Testing_Sample.ipynb
Sample image for Reference:
https://drive.google.com/file/d/1aITxCLfK1NViosRCdE6iORTHtO9sDgYX/view?usp=sharing
Since I am new user I am unable to post an image. So I have attached the drive link of that image.
Advance thanks for sparing time on my question.

Issue modifying Jupyter Home Directory

At one point I set my Jupyter home directory to ~/Dropbox Unfortunately, because of the way Dropbox changed their folder name that location is now a symbolic link on my machine that points to a hidden directory. This causes the following error in Jupyter
Refusing to serve hidden directory '/Users/alex/Dropbox', via 404 Error
That's fine ... I'd like to now change my Jupyter home directory, but the issue I'm having is that I can't figure out where it's currently set.
I've checked my ~/.jupyter/jupyter_notebook_config.py but that seems to be unmodified from the default.
The output of $jupyter --paths is :
config:
/Users/alex/.jupyter
/usr/local/Cellar/python#2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/etc/jupyter
/usr/local/etc/jupyter
/etc/jupyter
data:
/Users/alex/Library/Jupyter
/usr/local/Cellar/python#2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/share/jupyter
/usr/local/share/jupyter
/usr/share/jupyter
runtime:
/Users/alex/Library/Jupyter/runtime
Interestingly, the following directories don't exist.
/usr/local/Cellar/python#2/2.7.14_3/Frameworks/Python.framework/Versions/2.7/etc/jupyter
/usr/local/etc/jupyter
/etc/jupyter
Setting c.NotebookApp.notebook_dir = '/Users/alex/' in /Users/alex/.jupyter/jupyter_notebook_config.py seems to have no effect.
$jupyter notebook
[I 18:26:34.756 NotebookApp] [nb_conda_kernels] enabled, 4 kernels found
[I 18:26:35.257 NotebookApp] The port 8888 is already in use, trying another port.
[I 18:26:35.258 NotebookApp] The port 8889 is already in use, trying another port.
[I 18:26:35.259 NotebookApp] The port 8890 is already in use, trying another port.
[I 18:26:35.260 NotebookApp] The port 8891 is already in use, trying another port.
[I 18:26:36.299 NotebookApp] [nb_anacondacloud] enabled
[I 18:26:36.304 NotebookApp] [nb_conda] enabled
[I 18:26:36.382 NotebookApp] ✓ nbpresent HTML export ENABLED
[W 18:26:36.382 NotebookApp] ✗ nbpresent PDF export DISABLED: No module named 'nbbrowserpdf'
[I 18:26:36.388 NotebookApp] Serving notebooks from local directory: /Users/alex
[I 18:26:36.388 NotebookApp] 0 active kernels
[I 18:26:36.388 NotebookApp] The Jupyter Notebook is running at:
[I 18:26:36.388 NotebookApp] http://localhost:8892/?token=289948463daed06187325be63202f620b812dddc14f2918a
[I 18:26:36.388 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 18:26:36.389 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8892/?token=289948463daed06187325be63202f620b812dddc14f2918a
[I 18:26:36.717 NotebookApp] Accepting one-time-token-authenticated connection from ::1
[I 18:26:37.252 NotebookApp] Refusing to serve hidden directory '/Users/alex/Dropbox', via 404 Error
[W 18:26:37.252 NotebookApp] 404 GET /api/contents?type=directory&_=1526088397023 (::1): directory does not exist: 'Dropbox'
[W 18:26:37.252 NotebookApp] directory does not exist: 'Dropbox'
[W 18:26:37.253 NotebookApp] 404 GET /api/contents?type=directory&_=1526088397023 (::1) 15.70ms referer=http://localhost:8892/tree
Where could the Jupyter home directory be set from?
It is the intended behavior of jupyter notebook to throw a 404 when starting it from a hidden folder.
Generally, jupyter notebook will start in the folder where you invoke the jupyter notebook command. So cd into the directory where you want it to run from, and issue jupyter notebook there.
If that doesn't work, you can try forcing the directory with a command line argument like jupyter notebook --notebook-dir=NEWDIR.
Otherwise, there is a global config and a local (per user) one you refer above. If the local is the default, then you probably changed the global config earlier. If you change your local config in ~/.jupyter/jupyter_notebook_config.py to the new value that should override the global config.
To clean up the global config, look for it in /etc/jupyter or /usr/local/etc/jupyter/ on Unix or %PROGRAMDATA%\jupyter\ in Windows.
You can list the current config paths used with the command jupyter --paths. More info in the manual.

IPython notebook launched, but cannot login via Browser

I am trying to Login my Notebook via Browser, but Chrome shows "This webpage is not available"
I have the following on my terminal:
[ec2-user#ip-172-31-24-217 .ipython]$ ipython notebook --profile=nbserver
[I 11:31:38.289 NotebookApp] Using existing profile dir: u'/home/ec2-user/anaconda/.ipython/profile_nbserver'
[I 11:31:38.295 NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
[I 11:31:38.310 NotebookApp] Serving notebooks from local directory: /home/ec2-user/anaconda/.ipython
[I 11:31:38.311 NotebookApp] 0 active kernels
[I 11:31:38.311 NotebookApp] The IPython Notebook is running at: https://[all ip addresses on your system]:8888/
[I 11:31:38.311 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Can someone helps figure out what there is 0 active kernels? I have add the following in my ipython_nootbook_config.py file
#kernel config
c.IPkernelApp.pylab='inline' # if you want plotting support always
#Notebook config
c.NotebookApp.certfile=u'/home/ec2-user/anaconda/certificates/mycert.pem'
c.NotebookApp.ip='*'
c.NotebookApp.open_browser=False
c.NotebookApp.password=u'sha1:0d4773e470e5:2a91dcf5a15875f15c4ad18f9d3
4c95be563f804'
#It is a good idea to put it on a known, fixed port
c.NotebookApp.port=8888
#-------------------------
The number of running kernel has nothing to do with that.
Which page Are you visiting ? http://<ip>:8888 ? did you forgot the s in https ? Do you have Proxy settings ? Sophos antivirus ? On a Company network ?

Resources