I you need to "just" your code run notebooks in GCP there is a service for that: AI Platform Notebooks.

From your notebook instance you can work and download data you need, just be sure your instance has the resources (memory and CPU) you'll need, and do not forget to shut the instance down when you're not using it to avoid charges.

If a notebook is too much for you, you can always run everything in a compute instance (that's a virtual machine). Just launch it from the web and ssh to it with the web application (no need to install ssh, etc.), then you can upload the code into the instance. Just remenber to use a small instance one to start ;-)

Answer from Iñigo González on Stack Overflow
🌐
Google
codelabs.developers.google.com › codelabs › cloud-run-hello-python3
Hello Cloud Run with Python | Google Codelabs
March 20, 2026 - For the list of currently supported regions, see Cloud Run (fully managed) locations. ... gcloud run deploy helloworld-python \ --source .
🌐
Google
docs.cloud.google.com › cloud run › quickstart: build and create a python job in cloud run
Quickstart: build and create a Python job in Cloud Run | Google Cloud Documentation
Learn how to create a simple Cloud Run job, then deploy from source, which automatically packages your code into a container image, uploads the container image to Artifact Registry, and then deploys to Cloud Run.
Discussions

google cloud platform - Running basic Python script on GCP - Stack Overflow
I know this is basic but I am really struggling on how to get started and am so so so frustrated. I have developed the basis of my app on my windows pc using juypter notebooks and now want to start More on stackoverflow.com
🌐 stackoverflow.com
Automating Python with Google Cloud
This tutorial is great. I really wanted to learn this. More on reddit.com
🌐 r/Python
30
120
March 28, 2024
What's the best way to run python scripts on the cloud to process Google Sheets data?
There’s probably 100 ways to do this, but I’ve done something similar using google cloud platform services. I’d use cloud functions to run the script. Use gspread to interact with your sheet. Not sure what the best option is to save the output to google drive, but there are some google client libraries that can probably assist with that. You’ll need to sort out Auth and permissions, which can be a pain but is doable. You can trigger the cloud function on a schedule, or manually, or whatever other triggering mechanism you want to use. Depending on what you are doing, you’d probably stay in the free tier. More on reddit.com
🌐 r/pythontips
9
3
March 16, 2024
Running a python script on Google Cloud Compute Engine - Stack Overflow
The data set is quite big, and training takes forever. I was alerted to the option of running my script on the Google Cloud Compute Engine. I tried to set this up, but did not succeed (yet). ... Can anyone help me with importing and running my python script into the Google Cloud. More on stackoverflow.com
🌐 stackoverflow.com
🌐
Davidmuraya
davidmuraya.com › blog › python-google-cloud-functions-guide
How to Run Python Scripts in the Cloud with Google Cloud Functions
December 3, 2025 - To run it, you would execute python main.py in your terminal. This approach confirms your logic works and that you are handling environment variables correctly before you deploy. Newer (2nd gen) Cloud Functions are built on top of Cloud Run.
🌐
Google
docs.cloud.google.com › python › getting started with python on compute engine
Getting started with Python on Compute Engine | Google Cloud Documentation
From Cloud Shell, you can deploy to a single Compute Engine instance virtual machine (VM) which runs your app. You need a way to instruct your instance to download and run your code. An instance can have a startup script that runs whenever the instance is started or restarted. # Install or update needed software apt-get update apt-get install -yq git supervisor python python-pip python3-distutils pip install --upgrade pip virtualenv # Fetch source code export HOME=/root git clone https://github.com/GoogleCloudPlatform/getting-started-python.git /opt/app # Install Cloud Ops Agent sudo bash /opt
🌐
Reddit
reddit.com › r/python › automating python with google cloud
r/Python on Reddit: Automating Python with Google Cloud
March 28, 2024 -

I just published a tutorial series on how to automate a Python script in Google Cloud using Cloud Functions and/or Cloud Run. Feedback would be great. Thanks!

  • Automating Python with Google Cloud

    • Automating Python with Google Cloud Functions

    • Automating Python with Google Cloud Run

Find elsewhere
🌐
Medium
medium.com › @markwkiehl › python-web-app-in-google-cloud-run-cf4162636e33
Python Web App in Google Cloud Run | by Mark W Kiehl | Medium
April 27, 2025 - You literally need only sequentially run seven batch files in sequence from a Windows command prompt window and you will have a online production ready application! The batch files execute Docker and gcloud command line interface (CLI) commands. By inspecting the batch files, you can see the commands executed. A single file named “gcp_constants.bat” holds the project specific variables such as the Python script name, Google Cloud project name, Cloud Storage Bucket name, etc.
🌐
PyPI
pypi.org › project › google-cloud-run
google-cloud-run · PyPI
python3 -m venv <your-env> source <your-env>/bin/activate pip install google-cloud-run · py -m venv <your-env> .\<your-env>\Scripts\activate pip install google-cloud-run
      » pip install google-cloud-run
    
🌐
C2cglobal
c2cglobal.com › articles › how-to-run-python-on-google-cloud-1356
How to Run Python on Google Cloud
Generally speaking, however, any code deployed in Google Cloud is run by a virtual machine (VM). Kubernetes, Docker, and even Anthos make application modernization possible for large applications. In the case of smaller scripts and deployments, a customizable VM instance is adequate for running Python script on Google Cloud and determining processor size, the amount of RAM, and even the operating system of choice for running applications.
Top answer
1 of 5
39

I finally figured this out so I'll post the same answer on my own post that worked for me here. Using Debian Stretch on my VM. I'm assuming you already uploaded your file(s) to the VM and that you are in the same directory of your script.

  1. Make your script an executable

    chmod +x myscript.py
    
  2. Run the nohup command to execute the script in the background. The & option ensures that the process stays alive after exiting. I've added the shebang line to my python script so there's no need to call python here

    nohup /path/to/script/myscript.py &
    
  3. Logout from the shell if you want

    logout
    

Done! Now your script is up and running. You can login back and make sure that your process is still alive by checking the output of this command:

ps -e | grep myscript.py

If anything went wrong, you can check out the nohup.out file to see the output of your script:

cat nohup.out
2 of 5
9

There is even a simpler approach to to run code in the background in gcp and in every linux terminal: using screen linux

Create a new background terminal window:

screen -S WRITE_A_NAME_OF_YOUR_CHOIC_HERE

now you are in a background window in the terminal. Run your code:

python3 mycode.py

Exit screen with the hotkeys and the job will keep running on the background.

ctrl + A + D

You can close all windows now. If you wanna go back and see what's happening. Log again in your terminal. And tap the following.

screen -ls 

This one will give you the list of the created "windows". Now find yours and tap

screen -r WRITE_NAME_OF_YOUR_WINDOW

And there you have it :D You can find more commands here

🌐
Anderfernandez
anderfernandez.com › en › blog › automate-python-script-google-cloud
How to automate a Python script on Google Cloud - Ander Fernández
In this post I explain step by step how you can automate a Python script in Google Cloud with Cloud Functions, Cloud Scheduler and Pub/Sub.
🌐
DEV Community
dev.to › njoguu › running-a-python-script-on-google-cloud-in-2023-a-step-by-step-guide-272k
Running a Python Script on Google Cloud in 2023: A Step-by-Step Guide - DEV Community
May 31, 2023 - In this step-by-step guide, we covered the process of creating a VM instance, connecting to it, installing Python, pip, Git, and tmux, and running a Python file from a cloned repository. As the world of technology continues to evolve, Google Cloud remains at the forefront of innovation, providing developers with powerful tools and services to bring their Python applications to life. So, go ahead and unleash the full potential of your Python scripts on Google Cloud.
🌐
GitHub
github.com › GoogleCloudPlatform › python-docs-samples
GitHub - GoogleCloudPlatform/python-docs-samples: Code samples used on cloud.google.com · GitHub
2 weeks ago - Read more about Google Cloud Platform Authentication. Change directory to one of the sample folders, e.g. logging/cloud-client: ... Create a virtualenv. Samples are compatible with Python 3.6+. ... Install the dependencies needed to run the samples.
Starred by 8K users
Forked by 6.7K users
Languages   Jupyter Notebook 83.5% | Python 15.5% | JavaScript 0.7% | HTML 0.1% | Shell 0.1% | Dockerfile 0.1%
🌐
GitHub
github.com › GoogleCloudPlatform › cloud-run-samples
GitHub - GoogleCloudPlatform/cloud-run-samples: Samples for Cloud Run · GitHub
This repository contains sample applications used in Cloud Run documentation.
Starred by 300 users
Forked by 113 users
Languages   Shell 42.3% | Dockerfile 22.8% | Python 19.3% | Go 15.6%