Launch Jupyterlab on Google Cloud Platform and Publish to Kyso


This is a short guide to setting up and running a Jupyterlab environment on an Google Cloud instance. We have recently made a cool new Jupyterlab extension that allows anyone to publish their Jupyter notebooks directly to the web as awesome data blogs from anywhere.

1 . Create a free account in Google Cloud with $300 Credit


If you don't already have a Google Cloud account, head on over to GCP and sign up for a free account (Google Cloud provides 300$ credit). Note that you will have to enter your payment information and verify your account for this step.

If you do already have an account and haven't already activated your free trial, there should be an info bar at the top of your dashboard with a link to do just that. Once you're all set up, navivgate over to the console.

2. Create a new project

Loading output library...

Click on the 3 dots at the top left of the screen and create a new project. Note that you can also use an existing project.

3. Create and Configure VM instance


Ok, now we need to create our virtual machine. Back on the console dashboard, click on the 3 lines in upper left corner to reveal the left-hand side navbar.

Go to VM Instances under VM Instances.

Loading output library...

Now we have to create the instance. Hit Create.

Time to configure our instance. Name the instance. Google's Compute Engine (GCE) provides various type of VM, with various CPU types, operating system and memory. Also, be sure to choose the right zone. Click here for details on the different zones. If you click on Customize, you will be able to find options for using GPUs.

Loading output library...

We've also set some initial firewall rules above for access to the remote server, HTTP & HTTPS to allow specific network traffic for when we connect to the Jupyerlab App.

Now click on Create and your instance is ready to go! Note that this may take a minute or two. The green indicates that our instance is active. Be careful with this, as your account will continue to be charged as long as the instance is active, regardless of whether or not it is in use.

4. Confirm Configuration and Set Firewall Rules

Loading output library...

Before we go to use our VM, it's a good thing to confirm the connection. First of all, check that the IP address is static. Click on the 3 dots on the left-hand side of your instance on the VM Instances page.

Click View network details and then External IP Addresses on left-hand side toolbar of the next page. You will see the ip address we set in the last step. Ensure that the Type is static. If not, change it.

Loading output library...

Secondly, we need to set the Firewall rules for incoming traffic, necessary for launching and connecting to Jupyterlab on the instance. On the Network Interface Details page, go to Firewall Rules (on left_hand side) and click Create Firewall Rule (top of page).

Name your firewall rule and descriptions. Under protocols and ports you can choose any port range. Leave all other settings as the defaults. When ready click on the create button. See the image below for the way I've configured it.

Loading output library...

5. Connect to your Instance via SSH


Back on the VM Instances page, click on SSH to connect to the remote server. This will open a command window. You are now inside the VM. Alternatively you can can ssh into the instance from another ssh client. For this guide, we'll stick to the simpler option.

Loading output library...

6. Set Up Data Science Environment


Before we get gather our toolset, we should update our server's software with the following two commands:

sudo apt-get update

sudo apt-get install

Now, let's get the latest Anaconda build for linux. Enter:

to download the build. Now execute the installer:


Notice: If you see the warning bzip2 does not appear to be installed, this may cause problems below, this process may fail. If so, please execute the following command below, before proceeding:

sudo apt-get install bzip2

And follow the on-screen instructions. The defaults should work fine, but make sure you answer yes to the last question about prepending the install location to PATH.

To make use of Anaconda right away, source your bashrc:

source ~/.bashrc

If the installer doesn't allow you to set the Anaconda3 install location to PATH in your /home/"username"/.bashrc you can set it manually:

export PATH=/home/

Now let's launch our app!

Make a separate folder for our notebooks and cd into that directory:

mkdir notebooks

cd notebooks

7. Launching JupyterLab


It’s time to get the Jupyter Lab environment going. Initiate Jupyterlab in your notebooks directory with the following command:

jupyter lab --ip= --port=8000

which is the source and port I set earlier when configuring the firewall rules.

You should see some script in the VM terminal that shows the Jupyter environment is running:

Open a brower on your local machine, and in the address bar enter:

where is the static IP address of your VM, and 8000 is the port the notebook is running on. So there you have it — a fully functioning Jupyter Lab setup on your local browser, but operating on a remote VM.

8. Install Kyso's Publish Extension


The next step is to download Kyso's very own Jupyterlab extension. You can take a look at our documentation on Github here. The prerequisites are Jupyterlab 0.34 (or later) and a Kyso account.

You can check your Jupyterlab version by running:

jupyter lab --version

To install the extension, run the following.

For Jupyter Lab 0.35:

jupyter labextension install @kyso/jupyterlab

For Jupyter Lab 0.34:

jupyter labextension install @kyso/jupyterlab@jupyterlab-0.34.9

Note that this install requires node 5 or later. If you encounter any issues such as ValueError: Please install nodejs 5+ and npm before continuing installation when installing the above run the following & then install the extension:

curl -sL | sudo -E bash -

sudo apt-get install nodejs -y

Once installed, refresh the page & you will see the Kyso option in the top navbar. You are now able to publish awesome data blogs directly to Kyso from Google Cloud!

Loading output library...