IPython in Safari: websocket connection failure - python

Despite being listed in the ipython-notebook doc as one of the supported browsers, Safari 5.1.10 running on OSX 10.6.8(64bit) can not run IPython-notebook fully functionally. ipython version 2.2.0, in anaconda python environment.
Safari displays the list of notebooks OK. Every aspects seem to be fine until one opens (or creates a new) notebook. A error message shows up:
"A WebSocket connection could not be established.
You will NOT be able to run code.
Check your network connection or notebook server configuration."
Basically the cell shows up alright, but you can't run them.
Firefox 32.0.3 can, however, fully functions with IPython notebook. Therefore it is not a IPython notebook problem. Therefore there is no error message in the terminal, i.e:
6600sls-Mac-Pro:~ bio101sl$ ipython notebook --no-browser
2014-11-11 12:23:39.339 [NotebookApp] Using existing profile dir: u'/Users/bio101sl/.ipython/profile_default'
2014-11-11 12:23:39.369 [NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-11-11 12:23:39.541 [NotebookApp] Serving notebooks from local directory: /Users/bio101sl/IPython_NB
2014-11-11 12:23:39.542 [NotebookApp] 0 active kernels
2014-11-11 12:23:39.542 [NotebookApp] The IPython Notebook is running at: http://localhost:8888/
2014-11-11 12:23:39.542 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Seems to be a Safari - websocket related problem. Is there any settings in Safari has to be changed to get it work? Unfortunately ipython-notebook doc doesn't provide any hint on that.

Turns out not to be a browser issue either. It has to do with the tornado 4.0.2 shipped with anaconda, which is not compatible with Safari 5.1.10. Downgrade tornado to 3.2.2 solved the problem, in terminal:
conda install tornado=3.2
3.2.2 appears to be the last version that will work with Safari 5.1.10

I had similar problem using Safari 5.1.7 on Windows. Solution: I set Chrome version 40.0.2214.115 m as default browser.

Related

jupyter notebook keeps CONNECTING TO KERNEL

The Jupyter notebook keeps saying Connecting to kernel, which never reaches finally popping an error,
A connection to the notebook server could not be established. The notebook will continue
trying to reconnect. Check your network connection or notebook server
configuration.
So the asterisk on the command line stays forever.
The strange part is, iPython on terminal works FINE.
Here are what I tried:
Change the browser from Chrome to Firefox
Change port number into something else than '8888'
Uninstalled the Jupyter and re-installed it
Anybody with similar issues?
I had a similar issue. It was caused by the tornado-package and I had to downgrade it.
sudo pip3 uninstall tornado
sudo pip3 install tornado==5.1.1
See Jupyter notebook: No connection to server because websocket connection fails
I have found this same issue, and identified it only happens with Chrome standard browser. Incognito Chrome or Firefox does not have the same issue of ipykernel not connecting.
For now I open jupyter in firefox using the following command from Terminal:
jupyter lab --browser Firefox
Not sure what the difference is with the browsers, but recently I have had an issue of not being able to access local files from chrome, so will look into this issue and see if that resolves it for Chrome standard browser.

Jupyter notebook run in chrome gets stuck on server restart

I start with a working jupyter setup, and everything works just fine. I can interrupt or restart the kernel from the notebook without any problems.
If, however, I change some jupyter configuration, or install some modules, and restart jupyter server - I have to wait for about 5 minutes for the open notebooks to recover access to the python kernel.
To reproduce the problem:
Start jupyter (local shell)
jupyter notebook
In chrome create a new notebook (python 3), which will result in a url like:
http://localhost:8888/notebooks/Untitled1.ipynb?kernel_name=python3
Create and run a single cell in that new notebook:
print(1)
Restart jupyter (Ctrl-C followed by [yes] to the prompt to exit), followed by:
jupyter notebook
Go to the same chrome tab with the same single cell notebook and click OK for the pop-up "Connection failed"
Observe the notebook showing: [Connecting to Kernel] without success.
Try to Restart the kernel via the menu, usually it gets stuck in [Kernel Starting...], and after several manually forced kernel restarts it supposedly succeeds [Kernel Created], but it's a false success, as trying to run the cells gives a [*] busy sign and nothing happens.
After some 5 min of waiting it recovers by itself.
Workarounds:
Reloading the notebook in the browser (i.e. hitting Reload at the browser level)
Restarting chrome
Software:
ubuntu 16.04
notebook 5.5.0
python 3.6.6
chrome 67
no adblock software enabled
empty ~/.jupyter (removed everything for the sake of the testing, so no extensions or custom configuration)
Same setup works fine in firefox on the same machine.
There are several tickets on github about the same from 2015 (e.g. this, but somehow they blame it on chrome and clearly the issue is still there 3 years later.
Any idea how to solve this?
Thank you.
And here is the log during the open notebook reconnect/restart process:
[I 22:54:09.032 NotebookApp] Kernel restarted: 9aa08efb-74b1-471c-ad0f-bb9dc3577c28
[W 22:54:09.343 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26
[W 22:54:45.348 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26
[W 22:55:37.359 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26
[W 22:57:01.367 NotebookApp] Replacing stale connection: 6cc8a446-1dc0-4c01-86ab-f95ae99c24af:10a12a1b834f43298fb9e6f344bc6b26
[I 22:57:41.337 NotebookApp] Adapting to protocol v5.1 for kernel 9aa08efb-74b1-471c-ad0f-bb9dc3577c28
[W 22:57:41.350 NotebookApp] Replacing stale connection: 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6
[I 22:57:41.351 NotebookApp] Starting buffering for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6
[I 22:57:41.351 NotebookApp] Adapting to protocol v5.1 for kernel 9aa08efb-74b1-471c-ad0f-bb9dc3577c28
[I 22:57:41.352 NotebookApp] Restoring connection for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6
[I 22:57:49.324 NotebookApp] Starting buffering for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6
[I 22:57:49.327 NotebookApp] Adapting to protocol v5.1 for kernel 9aa08efb-74b1-471c-ad0f-bb9dc3577c28
[I 22:57:49.328 NotebookApp] Restoring connection for 9aa08efb-74b1-471c-ad0f-bb9dc3577c28:768880fb9a244da99735e983bd6c36c6
If you're not using the multi-user environment, the solution is to disable the security feature that prevents the authentication token used to launch the browser from being visible (which can be hijacked by other users on the same computer).
If you don't already have a jupyter notebook config file (usually ~/.jupyter/jupyter_notebook_config.py on linux):
Create it:
$ jupyter notebook --generate-config
Open the autogenerated file in a text editor and find the line:
#c.NotebookApp.use_redirect_file = True
Uncomment that line if it's commented out
Replace True with False
If you already have the config file and it doesn't have this setting, simply add to it:
c.NotebookApp.use_redirect_file = False
After changing the config file, you need to restart the jupyter server.
Note that you need jupyter-notebook >= 6.0.3 for this feature to work.
Finally, remember after every jupyter server restart you must reload each notebook for this to work. Only restarting the kernel will not solve this issue (even though it misleadingly says that kernel has been restarted).
It's a security feature, There's no wrong with chrome, it just auto-reload after 5 minutes because you switch between tabs somehow.
if you open a site when logged in ,all you see is the main site url, (not your password) , the same for the new jupyter notebook , you need a special (random) key works just like a password to get the jupyter server working first place before starting any kernels, and that happen automatically when you fire jupyter and the "main" tab opens, the browser keep the key for any new tab opened (or refreshed )
you are simply logged out when you keep the old-page unrefreshed,
this feature used to protect you from people watching what you send to a public web server
I still don't see any use of your case though (keep the page but restart the server), it's like halting the back-end but expecting the front-end to still function!

Access Jupyter Notebook installed on EMR 4.3.0 in browser

I have launched an AWS EMR cluster following the steps on the EMR page. After connecting through SSH (putty in Windows 7) and enabling foxyproxy (Chrome), it launched fine and can be accessed in my laptop browser.
Pyspark and sparkR come with the EMR Spark 1.6.0 installation and work perfectly in the terminal.
The ports for Hue etc. work fine in the following format:
ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com:/
I installed Jupyter by following the steps on http://jupyter.readthedocs.org/en/latest/install.html#using-pip
sudo pip install jupyter
I opened a new notebook with
jupyter notebook
It opened a browser in the terminal that I shut down. It gave the following output:
[I 14:32:12.001 NotebookApp] Writing notebook server cookie secret to /home/hadoop/.local/share/jupyter/runtime/notebook_cookie_secret
[I 14:32:12.033 NotebookApp] The port 8888 is already in use, trying another random port.
[I 14:32:12.037 NotebookApp] Serving notebooks from local directory: /home/hadoop
[I 14:32:12.037 NotebookApp] 0 active kernels
[I 14:32:12.038 NotebookApp] The Jupyter Notebook is running at: http://localhost:8889/
[I 14:32:12.038 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
I tried accessing it in my browser by:
localhost:8889/
(didn't work of course)
then by:
ec2-xx-xxx-xxx-xxx.us-west-2.compute.amazonaws.com:8889/
(replacing the x's), but this gave an error as well.
This webpage is not available
ERR_CONNECTION_RESET
So how can I access Jupyter in my local browser when it has been installed on the head node of an EMR cluster?
I haven't actually used Jupyter yet, but I tried installing and running it like you did, and I noticed that Jupyter is configured by default to listen only on localhost, which is why you can't access it from your browser.
I then found that running "jupyter notebook --generate-config" would generate a config file ~/.jupyter/jupyter_notebook_config.py, which you can edit in order to make it listen on 0.0.0.0 instead of localhost. Just change c.NotebookApp.ip to '0.0.0.0' and uncomment the line.
After doing this, I was able to access Jupyter from my browser using a URL like http://ip-10-168-157-117.ec2.internal:8888/. (Mine is listening on port 8888 by default, but I'm assuming yours started on port 8889 due to having Hue installed and listening on port 8888 already.)

iPython notebook can't connect to kernel on google-compute-engine

I've been trying to get ipython/jupyter notebook running as a notebook server on Google Compute Engine (Ubuntu 14.04 VM), but can't connect to the Python kernel.
I started with the latest Anaconda distribution. I can connect to the notebook server from my local machine via the web, browse the directory tree of the VM, and create new notebook, but never connects to the kernel (orange message in the upper right of Jupyter). The notebook port (8888) is open in the firewall settings. iPython notebook returns the following:
[I 19:21:10.152 NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
[I 19:21:10.169 NotebookApp] Serving notebooks from local directory: /home/rattlerray
[I 19:21:10.170 NotebookApp] 0 active kernels
[I 19:21:10.170 NotebookApp] The IPython Notebook is running at: https://[all ip addresses on your system]:8888/
[I 19:21:10.170 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[I 19:22:13.835 NotebookApp] 302 GET / (98.169.96.157) 0.85ms
[I 19:22:31.902 NotebookApp] Creating new notebook in
[I 19:22:33.634 NotebookApp] Kernel started: 011d8a15-0e4a-448a-b02a-4121780e4bb6
If anyone has run into this before and can offer some things to check, I'd appreciate it. Googling around hasn't helped and I'd really like to get this working on the cloud. Thanks!
I am using EC2 but encounter same problem.
I uses SSL told in the tutorial, after login and open a notebook in Safari always showing "Connecting to kernel". Then I try Chrome, which gives warning about certificate but works fine.
Then I comment the certificate in config file, then open in Safari it works fine.
If you are using Firefox, may be this issue Unable to contact kernel in Firefox after updating to ipython 3.0
Hope this will help.
Update:
The issue is reported on Github: https://github.com/ipython/ipython/issues/8621. As said in the post, this is the limitation of Safari. If you still want to use SSL to visit Notebook, you have to add the certificate into your keychain and trust it. Check the help posted by Apple: https://support.apple.com/kb/PH18677?locale=en_US
Another way you can connect to your IPython (Jupyter) Notebook server is by opening an SSH tunnel with port forwarding. I wrote a how-to post describing my own workflow. I'm using Google Compute Engine from within Chrome but many of the steps are analogous to other setup variations:
https://stharrold.github.io/20151208-ipynb-on-gce-from-chrome.html
Excerpt:
"""
Brief setup routine:
* Start [your] virtual machine instance.
* Start a Jupyter Notebook server on the instance:
$ jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser &
$ disown 1234 (where 1234 is the process ID)
* Create an SSH tunnel to forward a local port to the server's port on the instance:
$ ssh -f -N -L localhost:8888:0.0.0.0:8888 samuel_harrold#123.123.123.123
For [the] Chrome [app] Secure Shell, omit -f to keep the tunnel open (see screenshot [in post]).
* View the server at http://localhost:8888
"""
Additional details are in the post.

How to prevent overlap of cells in ipython notebook

I've been working on a locally hosted notebook for a while with no problems. However, I recently re-opened the notebook and found all of my cells to be overlapping, as shown in the image below:
If I move the cells up and down again they seem to re-align correctly. The only change I can think of that may have caused this was that I recently updated my anaconda package. All of the output to the console appears normal to me.
2014-10-10 08:22:45.531 [NotebookApp] Using existing profile dir: u'/Users/uname/.ipython/profile_default'
2014-10-10 08:22:45.535 [NotebookApp] Using MathJax from CDN: https://cdn.mathjax.org/mathjax/latest/MathJax.js
2014-10-10 08:22:45.726 [NotebookApp] Serving notebooks from local directory: /Users/uname/cwd
2014-10-10 08:22:45.727 [NotebookApp] 0 active kernels
2014-10-10 08:22:45.727 [NotebookApp] The IPython Notebook is running at: http://localhost:8888/
2014-10-10 08:22:45.727 [NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
2014-10-10 08:23:00.197 [NotebookApp] Kernel started: fa1fcfaf-c04f-4af0-a8da-6199a5e1d7ca
Any idea what might be causing this?
System Info:
Python 2.7.8 :: Anaconda 2.1.0 (x86_64)
Mac OS X Version 10.9.4
Google Chrome Version 39.0.2171.13 beta (64-bit)
Downgrade chrome. V39.x is supposed to be dev. Bug is apparently fixed on chrome canary.
Works perfectly fine in Firefox.
Downgrading chrome might cause some security vulnerabilities to be exposed.

Categories

Resources