How to run a python script on GCP Compute Engine?
First, you will need to install Cloud SDK: https://cloud.google.com/sdk/downloads#apt-get

Then, the simplest way is to run your script through your Terminal (mac and I presume the instructions also work on Linux):


Configure your project: gcloud config set project insert_your_project_name
Set up SSH keys: gcloud compute config-ssh
Connect to the VM: gcloud beta compute ssh vm_name --internal-ip
Run script: python your_script.py


You can also connect PyCharm directly to GCP and run everything on your VM but you will need PyCharm Pro, otherwise the deployment option is not available. Let me know if this works.

Also, if you want to use the interactive version of setting your project then in step 1 do this instead: gcloud init