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.
You can install Jupyter Notebook with two different methods
- 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.
- Install with
- If you are installing with
pipyou need to follow all steps below.
- If you are installing with
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
Activate the virtual environment by typing
Your prompt should change to indicate that you are now operating within a Python virtual environment. It will look something like this:
Install Jupyter Notebook
Now you can install Jupyter Notebook using
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
- Click Create
Configure Jupyter Notebook
By default Jypyter Notebook listens on localhost only, so you need to create a configuration to allow external connections.
jupyter notebook --generate-config
Now a configuration file will be created in
Edit the file and find
c.NotebookApp.ip and remove the
# and replace
sudo nano /home/username/.jupyter/jupyter_notebook_config.py
So the final code will be like this:
c.NotebookApp.ip = '0.0.0.0'
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.
Visit your IP Address with port
http://IP_ADDRESS:8888/)on your bowser.
Login using the password you set early.
Now you can write codes, equations, etc on your Jupyter Notebook.
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.