Setup and use Jupyter (IPython) Notebooks on AWS

Michael Galarnyk
Towards Data Science
3 min readAug 2, 2017

--

If you are having trouble following this tutorial or want to use JupyterHub on AWS, I made an updated tutorial (YouTube, blog).

A while ago, I wrote a post, “Start a Jupyter (IPython) Notebook Server on AWS”. While that approach allows for multiple people to access the server with just a password, it suffers from being complicated to setup. Most people just want to use a Jupyter Notebook using their AWS resources without the hassle. With that, here is how you do it.

Starting a Jupyter Notebook on AWS

  1. SSH to your EC2 instance. If you don’t know how to do this or would like a reference, please see this tutorial.
SSH Command used in the Video

2. Make sure you have installed Anaconda. If you don’t have it installed, you do it using this tutorial.

3. Type the following command in your terminal:

jupyter notebook --no-browser --port=8888
Expected Output of running the previous command

The reason why we add “ — no-browser” is because if we don’t, you might get an error like “Jupyter Notebook requires JavaScript”. Having said that, if you get that error, you can ignore the error by pressing Q and then press Y to confirm.

SSH to your Jupyter Notebook

4. Open a new terminal and SSH to your Jupyter Notebook. Your command should be similar to the one below. If you don’t know how to do this, please see tutorial.

ssh -i thisIsmyKey.pem -L 8000:localhost:8888 ubuntu@ec2–34–227–222–100.compute-1.amazonaws.com

-i Specifies an alternate identification file to use for public key authentication. Basically for this tutorial, I have my key in current directory.

-L specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side (AWS). This means that whatever is running on the second port number (i.e. 8888) on AWS will appear on the first port number (i.e. 8000) on your local computer. You should change 8888 to the port which Jupyter Notebook is running on. 99.9% of the time Jupyter will run on port 8888. Optionally change port 8000 to one of your choosing (for example, if 8000 is used by another process).

5. Open your browser and go to localhost:8000

You should get something similar to this

6. (Optional) If you want to use different conda environments (including the ability to access both Python 2 and Python 3 environments in Jupyter Notebooks, please see this tutorial).

Please let me know if you have any questions either here, on the youtube video page, or through Twitter!

--

--