Google Cloud Compute Engine

How to Set Up Jupyter Notebook on Ubuntu 18.04 in Google Cloud

Disclosure: This post may contain affiliate links, which means we may receive a commission if you click a link and purchase something that we recommended.

Pinterest LinkedIn Tumblr

How to Set Up Jupyter Notebook on Ubuntu 18.04 in Google Cloud. Jupyter is an open source software for interactive computing across many programming languages. Jupyter Notebook is a web application which is used to create and share live codes, equations, visualizations. This used in machine learning, data cleaning, numerical simulation, statistical modeling and many more.

In this guide you are going to learn how to setup Jupyter Notebook on Ubuntu in Google Cloud Platform.


Your Compute Engine Instance running, see the Setting up Compute Engine Instance.

Installation Methods

You can install Jupyter Notebook with two different methods

  1. Install using Anaconda. Learn to install Jupyter Notebook using Anaconda
    • If you are installing using Anaconda you can skip the below steps up to creating Firewall rules.
  2. Install with pip
    • If you are installing with pip you need to follow all steps below.

Install required packages

SSH to your Compute Engine instance and begin typing the following commands to start installing Jupyter.

sudo apt install python3-dev python3-pip

Create Python Virtual Environment for Jupyter Notebook

sudo -H pip3 install --upgrade pip
sudo -H pip3 install virtualenv
mkdir ~/myprojectdir
cd ~/myprojectdir
virtualenv myprojectenv

Activate the virtual environment by typing

source myprojectenv/bin/activate

Your prompt should change to indicate that you are now operating within a Python virtual environment. It will look something like this: (myprojectenv)[email protected]:~/myprojectdir$

Install Jupyter Notebook

Now you can install Jupyter Notebook using pip

pip install jupyter

Enable Firewall Rule

Once Jupyter Notebook is installed it will run on port 8888. So you need to create a Firewall rule to allow connections on port 8888. So lets create a firewall rule.

Go to Networking >> VPC Networks >> Firewall rules and click Create Firewall rule.

  • Enter a name
  • In Targets select All instances in the network
  • In Source IP ranges enter
  • In Protocols and ports check tcp and enter 8888
  • Click Create

Configure Jupyter Notebook

By default Jypyter Notebook listens on localhost only, so you need to create a configuration to allow external connections.

Generate Configuration

jupyter notebook --generate-config

Now a configuration file will be created in /home/username/.jupyter/

Edit the file and find c.NotebookApp.ip and remove the # and replace localhost with

sudo nano /home/username/.jupyter/

So the final code will be like this:

c.NotebookApp.ip = ''

Generate Password

Finally you can secure the application by creating a password.

jupyter notebook password

Enter the password and verify the password.

Test Jupyter Notebook

Now Jupyter Notebook is installed and also created a firewall rule to allow access on port 8888. Now start Jupyter notebook.

jupyter notebook

Visit your IP Address with port 8888 (http://IP_ADDRESS:8888/)on your bowser.

Jupyter Notebook Login

Login using the password you set early.

Jupyter notebook dashboard

Now you can write codes, equations, etc on your Jupyter Notebook.

Jupyter Notebook directory structure

You can click on Quit button to shutdown Jupyter Notebook server. For more set up and configuration details you can visit official docs here.


Jupyter Notebook is installed successfully on your Ubuntu 18.04 in Google Cloud.

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.