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?
Answer #1: If you're on Windows: pass -W ignore::DeprecationWarning as an argument to Python. Better though to resolve the issue, by casting to int. (Note that in Python 3.2, deprecation warnings are ignored by default.)
I eventually figured it out. Place:
import warnings warnings.filterwarnings('ignore')
inside ~/.ipython/profile_default/startup/disable-warnings.py
. I'm leaving this question and answer for the record in case anyone else comes across the same issue.
Quite often it is useful to see a warning once. This can be set by:
warnings.filterwarnings(action='once')
I hide the warnings in the pink boxes by running the following code in a cell:
from IPython.display import HTML HTML('''<script> code_show_err=false; function code_toggle_err() { if (code_show_err){ $('div.output_stderr').hide(); } else { $('div.output_stderr').show(); } code_show_err = !code_show_err } $( document ).ready(code_toggle_err); </script> To toggle on/off output_stderr, click <a href="javascript:code_toggle_err()">here</a>.''')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With