Viewing a single comment thread. View all comments

DigThatData t1_j8xxnpp wrote

unrelated to OP: what is the "best practice" method for a notebook to self-test if it's running in a colab environment? i think the method I'm currently using is something like

probably_colab = False
try:
    import google.colab
    probably_colab = True
except ImportError:
    pass

which I'm not a fan of for a variety of reasons. what would you recommend?

5

ckperry t1_j8ygjep wrote

[edit] I give up on formatting

We've never really worked on a foilproof way to detect if you're using Colab, but this might work a little better for you:

import sys probably_colab = False

if 'google.colab' in sys.modules: probably_colab = True

11

Captain_Cowboy t1_j8z1lv4 wrote

Maybe a little easier:

import sys
probably_colab = 'google.colab' in sys.modules
12