isjupyter#

isjupyter(detailed=False)[source]#

Check if a command is running inside a Jupyter notebook.

Returns true/false if detailed=False, or a string for the exact type of notebook (e.g., Google Colab) if detailed=True.

Parameters:
  • detailed (bool) – return a string of IPython/Jupyter type instead of true/false

  • verbose (bool) – print out additional information if IPython can’t be imported

Examples:

if sc.isjupyter():
    sc.options(jupyter=True)

if sc.isjupyter(detailed=True) == 'colab':
    print('You are running on Google Colab')

New in version 3.0.0.