Wednesday, April 27, 2022

[FIXED] How to suppress graphviz warnings in Python 3?

Issue

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



Answered By - RemarkableBucket
Answer Checked By - Mildred Charles (PHPFixing Admin)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.