Saturday, May 18, 2024
GCP Juara GCP Python

App Dev: Setting up a Development Environment – Python

app

“App Dev: Setting up a Development Environment – Python”

Pengantar

Google Cloud terdiri dari sekumpulan aset fisik, seperti komputer dan hard disk drive, serta sumber daya virtual, seperti mesin virtual (VM), yang terdapat di pusat data Google di seluruh dunia. Setiap lokasi pusat data berada di wilayah global. Wilayah meliputi AS Tengah, Eropa Barat, dan Asia Timur. Setiap wilayah merupakan kumpulan zona, yang terisolasi satu sama lain di dalam wilayah tersebut. Setiap zona diidentifikasi dengan nama yang menggabungkan pengenal huruf dengan nama wilayah. Misalnya, zona a di kawasan Asia Timur diberi nama asia-east1-a.

Praktikum

Task 1. Create a Compute Engine Virtual Machine instance

Create and connect to a virtual machine

  • In the Console, click Navigation menu > Compute Engine > VM Instances.
  • On the VM Instances page, click Create Instance.
  • On the Create an instance page, for Name type dev-instance, and select a Region as us-east1 and Zone as us-east1-b.
  • In the Machine configuration section, for Series select N1.
  • In the Identity and API access section, select Allow full access to all Cloud APIs.
  • In the Firewall section, enable Allow HTTP traffic.
  • Leave the remaining settings as their defaults, and click Create.
  • On the VM instances page, in the dev-instance row, click SSH.

Install software on the VM instance

sudo apt-get update

sudo apt-get install git

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

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

sudo python3 get-pip.py

Task 2. Configure the VM to run application software

Verify Python installation

  • Still in the SSH window, verify the installation by checking the Python and pip version:
python3 --version
pip3 --version
  • Clone the class repository:
git clone https://github.com/GoogleCloudPlatform/training-data-analyst
  • Change the working directory:
cd ~/training-data-analyst/courses/developingapps/python/devenv/
sudo python3 server.py
  • Return to the Cloud Console VM instances list (Navigation menu > Compute Engine > VM Instances), and click on the External IP address for the dev-instance.
  • Return to the SSH window, and stop the application by pressing Ctrl+C.
  • Install the Python packages needed to enumerate Compute Engine VM instances:
sudo pip3 install -r requirements.txt
  • Now list your instance in Cloud Shell. Enter the following command to run a simple Python application that lists Compute Engine instances. Replace <PROJECT_ID> with your Project ID and <YOUR_VM_ZONE> is the region you specified when you created your VM. Find these values on the VM instances page of the console:
python3 list-gce-instances.py <PROJECT_ID> --zone=<YOUR_VM_ZONE>

Penutup

Sahabat Blog Learning & Doing demikianlah penjelasan mengenai App Dev: Setting up a Development Environment – Python. Semoga Bermanfaat . Sampai ketemu lagi di postingan berikut nya.

(Visited 57 times, 1 visits today)

Similar Posts