How to Create Python Development Environment In Google Cloud Platform

How to Create Python Development Environment In Google Cloud Platform

In this post, you will learn how to create python application development environment in google cloud platform

In this post, you will learn how to create python application development environment in google cloud platform

Set up a Python development environment on Google Cloud Platform, using Google Compute Engine to create a virtual machine (VM) and installing software libraries for software development.

You perform the following tasks,

  • Provision a Google Compute Engine instance.
  • Connect to the instance using SSH.
  • Install a Python library on the instance.
  • Verify the software installation.

Prerequisites

  • Google cloud account

Follow the below steps to create a Python Application development environment in Google Cloud Platform.

Step 1

Login https://console.cloud.google.com/.

Step 2

Create and connect to a virtual machine,

  1. In the Console, click Navigation menu > Compute Engine > VM Instances.

This is image title

  1. On the VM Instances page, click Create.

  2. On the Create an instance page, for Name type dev-instance, and select a Region as us-central1 (Iowa) and Zone as us-central1-a.

  3. In the Identity and API access section, select Allow full access to all Cloud APIs.

  4. In the Firewall section, enable Allow HTTP traffic.

  5. Leave the remaining settings as their defaults, and click Create.

This is image title

It takes about 20 seconds for the VM to be provisioned and started

On the VM instances page, in the dev-instance row, click SSH.

This launches a browser-hosted SSH session. If you have a popup blocker, you may need to click twice.

There's no need to configure or manage SSH keys.

Step 3

Install software on the VM instance

In the SSH session, to update the Debian package list, execute the following command,

sudo apt-get update

To install Git, execute the following command,

sudo apt-get install git

When prompted, enter Y to continue, accepting the use of additional disk space.

To install Python, execute the following command,

sudo apt-get install python-setuptools python-dev build-essential

Again, when prompted, enter Y to continue, accepting the use of additional disk space.

To install pip, execute the following command,

_sudo easy_install pip

Step 4

Configure the VM to Run Application Software.

In this section, you verify the software installation on your VM and run some sample code.

Verify Python installation

Still in the SSH window, verify the installation by checking the Python and pip version,

python --version
pip --version

The output provides the version of Python and pip that you installed.

Clone the class repository,

git clone

Change the working directory,

cd ~/training-data-analyst/courses/developingapps/python/devenv/

Run a simple web server,

sudo python server.py

Step 5

Return to the Cloud Console VM instances list (Navigation menu > Compute Engine > Virtual Instances), and click on the External IP address for the dev-instance.

This is image title

A browser opens and displays a Hello GCP dev! message from Python.

Step 6

  1. Return to the SSH window, and stop the application by pressing Ctrl+c.

  2. Install the Python packages needed to enumerate Google Compute Engine VM instances,

sudo pip install -r requirements.txt

Step 7

Now list your instance in Cloud Shell. Enter the following command to run a simple Python application that lists Compute Engine instances. Replace with your GCP Project ID and is the region you specified when you created your VM. Find these values on the VM instances page of the console,

python list-gce-instances.py <PROJECT_ID> --zone=<YOUR_VM_ZONE>

Your instance name should appear in the SSH terminal window.

Output

This is image title

Summary

I hope you understood how to create a Python Application development environment in Google Cloud Platform. Stay tuned for more GCP environment articles.

Python Google Cloud Platform

What's new in Bootstrap 5 and when Bootstrap 5 release date?

How to Build Progressive Web Apps (PWA) using Angular 9

What is new features in Javascript ES2020 ECMAScript 2020

Deno Crash Course: Explore Deno and Create a full REST API with Deno

How to Build a Real-time Chat App with Deno and WebSockets

Convert HTML to Markdown Online

HTML entity encoder decoder Online

Random Password Generator Online

HTML Color Picker online | HEX Color Picker | RGB Color Picker

Multi-cloud Spending: 8 Tips To Lower Cost

Mismanagement of multi-cloud expense costs an arm and leg to business and its management has become a major pain point. Here we break down some crucial tips to take some of the management challenges off your plate and help you optimize your cloud spend.

What are the benefits of cloud migration? Reasons you should migrate

To move or not to move? Benefits are multifold when you are migrating to the cloud. Get the correct information to make your decision, with our cloud engineering expertise.

Getting Started with Python working on Google Cloud Functions

Writing Python cloud functions is easy and fun, as I will now demonstrate. To follow this tutorial you’ll need a Google Cloud Project, a local Python development environment and the gcloud SDK.

Model with TensorFlow and Serve on Google Cloud Platform

In this guide, we learn how to develop a TensorFlow model and serve it on the Google Cloud Platform (GCP). We consider a regression ...

Basic Data Types in Python | Python Web Development For Beginners

In the programming world, Data types play an important role. Each Variable is stored in different data types and responsible for various functions. Python had two different objects, and They are mutable and immutable objects.