()
True if running inside a Jupyter notebook.
True if running inside a Jupyter notebook.
True if running inside a Jupyter notebook .
def in_notebook():
    '''
    True if running inside a Jupyter notebook.
    '''
    # From https://stackoverflow.com/a/39662359/265298
    try:
        shell = get_ipython().__class__.__name__
        if shell == 'ZMQInteractiveShell':
            return True   # Jupyter notebook or qtconsole
        elif shell == 'TerminalInteractiveShell':
            return False  # Terminal running IPython
        else:
            return False  # Other type (?)
    except NameError:
        return False
def in_notebook ( ) : # From https://stackoverflow.com/a/39662359/265298 try : shell = get_ipython ( ) . __class__ . __name__ if shell == 'ZMQInteractiveShell' : return True # Jupyter notebook or qtconsole elif shell == 'TerminalInteractiveShell' : return False # Terminal running IPython else : return False # Other type (?) except NameError : return False