How to run py file from google drive

It executes the file and loads the Python file from my local drive; however, when I provide the link to my Google Drive file, it returns an error and fails to load my Python file. Please provide the correct code to load a Python file from Google Drive.

‘‘‘

import tkinter as tk

import subprocess

import sys

import requests

import io

import os

def launch_streamlit_app():

url =      'https://drive.google.com/file/d/17zZRiO0j1QW44pJIKk-Iq0F5eSfIloPw/view?usp=drive_link'     #### this is my google drive file stsub.py  link 



command = \[sys.executable, "-m", "streamlit", "run", "stsub.py"\]

#command = \[sys.executable, "-m", "streamlit", "run", "url"\]     this code did not run give error 

subprocess.Popen(command)
root = tk.Tk()

root.title(“Streamlit Launcher”)

launch_button = tk.Button(root, text=“Launch Streamlit App”, command=launch_streamlit_app)

launch_button.pack(pady=20)

root.mainloop()

‘‘‘

Google drive does not create static direct-to-download links for its files, probably to intentionally prevent things like this (for whatever reason).

You might have better luck with a Dropbox share link, where you change “dl=0” to “dl=1”

Shouldn’t OP use Google Colab? It’s like Jupyter but for Google and I think it can run Python files on the drive, read data files on Google Drive, etc. https://colab.research.google.com/

It’s free.

There are a bunch of sites that execute Python on a website that I’ve collected and they all have different features depending on what you want. Some sites are just for testing small programs or snippets of code.