'Trigger Python script located in Google Drive using Google Sheets

I have created a Python script (using Google Colab) and stored it on my Google Drive.

When the Python script runs it automatically reads a Google Sheet in the same location and generates a PDF report.

I would like to create a button in the Google Sheet which triggers this script and generates the report.



Solution 1:[1]

Answer

You can't run scripts from Drive even using Apps Script.

Apps Script runs on the server side and you have a Python script stored on Drive. It does not matter if you have both (Google Sheet and Python script) on the same location, since you are not allowed to run scripts from there, that would be a big security issue. When it comes to executing scripts such as Python, Ruby, etc, the only option to do it is on Google Cloud Platform by using Cloud Build or Compute Engine for instance. As a workaround, you could re-write your python script in Apps Script. Remember - you can't run apps script code directly from Drive either, only open it and run it from the editor.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jose Vasquez