pythonjupyter-notebookipythonwarnings

Hide all warnings in IPython


I need to produce a screencast of an IPython session, and to avoid confusing viewers, I want to disable all warnings emitted by warnings.warn calls from different packages. Is there a way to configure the ipythonrc file to automatically disable all such warnings?


Solution

  • Place:

    import warnings
    warnings.filterwarnings('ignore')
    

    inside ~/.ipython/profile_default/startup/disable-warnings.py.

    Quite often it is useful to see a warning once. This can be set by:

    warnings.filterwarnings(action='once')