pythongoogle-colaboratory

Cannot schedule Google Colab Pro+ when using Gspread, Selenium


I have a Colab notebook which connects to my Drive, authenticates for Gspread, downloads & installs Chromium with Selenium, downloads & uses XVFB and pyvirtualdisplay. The notebook runs several python .py files from my Drive.

When I try to schedule it, it fails to run. The copy of the notebook doesn't show any error.

from google.colab import auth
from google.auth import default
auth.authenticate_user()
import gspread
creds, _ = default()
gc = gspread.authorize(creds)
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
[...]

%run '/content/drive/MyDrive/scheduled_tasks/[...].py'
[...]

Are there any specific limitations to be able to successfully schedule a Colab Pro+ notebook to run in the background? Should I add something specific to my code?


Solution

  • After much trial and error, I managed to make it work. Here are my results:

        StdinNotImplementedError: raw_input was called, but this frontend does not support input requests.
    

    This means you cannot use any of the following:

    -- from google.colab import auth //auth.authenticate_user()
    -- gspread
    -- tqdm
    -- swifter
    -- likely other packages using tqdm or printing fancy progress bars
    

    You can do simple print statements.