Jupyter notebook + Google Cloud

Asier Serrano
1 min readOct 3, 2020

--

Fast and easy configuration, without external packages.

Picture by Asier Serrano

Once you are connected to your remote machine, follow these steps:

  1. Install jupyter (https://jupyter.org/install):
pip install jupyterlab
pip install notebook

2. Create the Jupyter configuration file:

jupyter notebook --generate-config

3. Edit it, it will be placed at ~/.jupyter/jupyter_notebook_config.py, and add these lines:

c = get_config()
c.IPKernelApp.pylab = 'inline'
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.port = N_PORT

4. Make external IP as static on the Google Cloud Platform interface of your account:

  • Networking > VPC Network > External IP addresses.
  • Change type from Ephemeral to Static.
  • You will see a popup window where you need to provide a name for the new static IP address. Save it and click Reserve.

5. Obtain your external IP address:

gcloud compute instances list

6. Open a port for connecting:

  • The number of port is N_PORT.
gcloud compute firewall-rules create <rule-name> --allow tcp:N_PORT 

7. Execute the jupyter notebook:

jupyter-notebook — no-browser — port=N_PORT

8. In your browser, go to:

http://EXTERNAL_IP:N_PORT

9. You will be asked your token, so execute:

jupyter-notebook list

Copy and paste it and you are done!

Thanks for reading my article :-)

--

--