20

I have some python code that, at some point, takes the axis means of a reasonably sparse array with nans in. Every time I run the code it raises a RuntimeWarning.

I know what's causing the warning, it's intentional, and it doesn't affect the output. It is, however, quite irritating to be presented with the warning every time I run the program - so, is there a cheap and nasty way to prevent them from being printed to the terminal?

2
  • Run your main script using the -W option like this: python -W ignore your_script.py Commented Jan 9, 2015 at 15:38
  • if it is written (as should be) to stderr then you can add 2>/dev/null to call Commented Jan 9, 2015 at 15:39

2 Answers 2

17

This may be useful to you, I think the issue has been pretty solved in this question: How to disable python warnings

Sign up to request clarification or add additional context in comments.

Comments

4

All what you need is suppress it exactly as described in official documentation: https://docs.python.org/2/library/warnings.html#temporarily-suppressing-warnings

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.