Image for post
Image for post

AWS (Amazon Web Services) has become a common name in the industry these days and if you are working with Python, chances are that you are already familiar with Jupyter (previously iPython) Notebooks. Although, if you are not familiar with Jupyter and you work with Python, then you are definitely missing on a very handy tool.

The reason for deploying Jupyter on AWS is to access and work with it from almost anywhere, just using a browser. So, let’s begin…

1. Login to your Amazon Management Console. If you don’t have an account yet, you can create one for free. You get 1 yr of free access to some of the services, which you can check out at this link

2. Create a new EC2 Instance with Ubuntu. If you are not familiar with how to create an EC2 instance, you can check out this video for reference.

3. The important thing to remember while creating the instance is to assign the security group settings as shown below

4. Launch your instance and ssh into it to perform the following operations

  • First of all we are going to use Anaconda Python Distribution for installing all the required Python libraries. This is a free distribution and we are going to use the Linux version of it. Remember to verify the latest version of the distribution from the site.
    $ wget
  • Next we will bash to run this .sh file. You need to accept the license terms and set the installation directory for the anaconda distribution. I use the default one, which is “/home/ubuntu/anaconda3/”. Also, it asks you to add the default path of anaconda python to your .bashrc profile. You can accept it or add it manually later.
  • Now you need to check, which python version you are using, just to confirm if Anaconda Python was installed and set correctly or not. You can do this by using
  • This will list the python your system is currently using. If it does not mentions the one from “…/anaconda3/…” folder, then you can use the following command to re-load your .bashrc, so as to set the correct python
  • Open the iPython terminal to get an encrypted password so as to use it for logging into our iPython Notebook Server. Remember to copy and save the output of this command, which will be an encrypted password, something like “sha1…”
  • and exit out of ipython terminal.
  • Now we’re going to create the configuration profile for our Jupyter Notebook server
  • (Optional step) You could also create a self-signed certificate for accessing the Notebooks over HTTPS
  • You will be prompted with some questions, please answer them to the best of your knowledge as some of these are required to successfully create the certificate.
  • It’s time to change the config settings of Jupyter
  • You will see a long list of configuration settings. You can go through each one of them and uncomment them as required. For simplicity, it’s easier to just add the following settings to the top of the file and leave the rest commented as it is.
  • Almost done with all the setup. Now it’s time to start our Jupyter notebook server. For this, let’s first create a new folder to store all the notebooks
  • and now START the notebook server

5. And that’s all folks... Now you can access your Notebooks — navigate to the DNS name, or Public IP of your instance, along with the port number. (By default, the browser adds “http” to the url. Please remember to update it to “https” if you’re using the self-signed certificate)

You will be asked by your browser to trust the certificate. Refer to screenshots below:

6. Login using the password you specified on the iPython terminal and you are good to go.

7. Note that if you close ssh access to your instance, your notebook server will not work. To keep it working, even when you close the ssh access to the server, you can use the following command

This will put your server process as no-hangup (nohup) and will keep it running even if you close the ssh access to the instance

8. Later, if you decide you want to stop this process, you have to find the process ID (PID) of this process. You can do so by navigating to your notebooks folder and using the command

which will list the PID of the nohup process which is running(if any). Then you can use the kill command to kill this process and stop your Jupyter notebook server.

replace <PID> with the ID of the process you get from the lsof command.

That’s it!! Now you have your Jupyter Notebooks on AWS EC2 instance and can work and use them from almost anywhere around the World.

Originally published at on February 16, 2015.

Machine Learning | Data Science | Blogger | NLP | CV 👨‍💻

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store