rjurney / Agile_Data_Code_2

Code for Agile Data Science 2.0, O'Reilly 2017, Second Edition
http://bit.ly/agile_data_science
MIT License
456 stars 306 forks source link

EC2 Jupyter Notebook malfunction #72

Closed sewald101 closed 5 years ago

sewald101 commented 6 years ago

Solved the problem described below by manually editing out the argument from /home/ubuntu/anaconda/lib/python3.5/site-packages/notebook/base/zmqhandlers.py.

The version of ec2_bootstrap.sh that I've accessed today has the jupyter configuration codes commented out.

I am unable to access the notebook at localhost:8888 (or at any other location) without first manually launching a jupyter session in an ssh console and then accessing it after an ssh mapping like this:

ssh -NfL 8888:localhost:8888 <ec2_alias>

When I do, I can launch a notebook, but when I create or run a new nb on the Python 3 kernel, I get an endless recurring series of these messages in the ec2 console in which jupyter is running.

[I 22:21:18.933 NotebookApp] Adapting to protocol v5.1 for kernel d4fe2e45-b151-466e-8ab3-b92239e789c4 [E 22:21:18.934 NotebookApp] Uncaught exception in /api/kernels/d4fe2e45-b151-466e-8ab3-b92239e789c4/channels Traceback (most recent call last): File "/home/ubuntu/anaconda/lib/python3.5/site-packages/tornado/websocket.py", line 498, in _run_callback result = callback(*args, **kwargs) File "/home/ubuntu/anaconda/lib/python3.5/site-packages/notebook/services/kernels/handlers.py", line 262, in open super(ZMQChannelsHandler, self).open() File "/home/ubuntu/anaconda/lib/python3.5/site-packages/notebook/base/zmqhandlers.py", line 176, in open self.send_ping, self.ping_interval, io_loop=loop, TypeError: init() got an unexpected keyword argument 'io_loop'

And, of course, the nb will not run any code in this condition.

Manually running in the console the commented out commands from ec2_boostrap.sh does not help. These commands:

jupyter-notebook --generate-config cp /home/ubuntu/Agile_Data_Code_2/jupyter_notebook_config.py /home/ubuntu/.jupyter/ cd /home/ubuntu/Agile_Data_Code_2 jupyter-notebook --ip=0.0.0.0 &

sewald101 commented 6 years ago

I continue to run down the rabbit hole with this problem. I terminated my agile_data_science EC2 and re-spun it up. And IT WORKED . . . ONCE. (I got a URL with a key and was able to access the nb from my browser.) But then after I stopped the EC2 between practice sessions (to save $$) and restarting, I could not access the nb again without getting the error message above in a continuous loop.

Accessing a nb should be easy, right? I've never had this problem with other EC2 instances on other projects. On a standard installation (running Python 2, btw), I usually do this in the ssh terminal, which yields a URL with a security key: jupyter notebook --no-browser --port=18888

Then this locally: ssh -NfL 18888:localhost:18888 <EC2 alias name>

Then paste the URL with key into the browser and bingo, it works.

That routine is not working for this Agile_DS EC2.

Neither does re-running jupyter-notebook --ip=0.0.0.0 What am I doing wrong?

rjurney commented 5 years ago

Now the notebook server runs on its own and all you have to do is run:

./ec2.sh
./ec2_create_tunnel.sh

Now after fifteen minutes for the server to configure, you should be able to go to http://localhost:8888

If you want to stop your machine, use the AWS console or AWS CLI. Then restart it that way. Copy the hostname from the AWS EC2 console and place it in your Agile_Data_Code_2/.ec2_hostname file. Now you can run ./ec2_kill_tunnel.sh to kill the old tunnels and ./ec2_create_tunnel.sh to create the ssh tunnels again.