Search code examples
python-3.xwarningsgraphviz

How to suppress graphviz warnings in Python 3?


I'm using the graphviz module to render a network of nodes and links.

I use small circles as node's shape, so the labels are intentionally bigger than the nodes.

As a consequence, I get the following warning:

"Warning: node 'wave', graph 'N' size too small for label"

'Wave' is just an example of a node's label.

I get lots of this warnings because of the high quantity of nodes (screencapture).

So, my question is: How can I suppress warnings like those?

The graphviz command I'm using is:

n.view()  # n is my digraph

I have already tried the suggestions from:

How to suppress a third-party warning using warnings.filterwarnings

How to redirect python warnings to a custom stream?

But nothing so far. Thanks in advance.


Solution

  • Try Eli Bendersky's excellent page: Redirecting all kinds of stdout in Python

    After replacing stdout with stderr, Eli's solution worked on graphviz for me.

    If you happen to be using Evince, Ubuntu's builtin PDF viewer, see:

    https://superuser.com/questions/980237/silence-evinces-warnings-in-ubuntu