Home > other >  How to use Graphviz Python module in Qgis Environment?
How to use Graphviz Python module in Qgis Environment?

Time:08-04

I installed the graphviz python module with pip commend python -m pip install graphviz

later i set the environment system variables

enter image description here

enter image description here

then tried in small code in Qgis python console

import graphviz

print('Graphviz running')
dot = graphviz.Digraph('YPN-PN-101', comment='SLD')
dot.node('YPN-CA-1', 'CABINATE')
dot.node('YPN-AN-1-1', 'AN1')
dot.node('YPN-AN-2-1', 'AN2')
dot.node('YPN-AN-3-1', 'AN3')
dot.node('YPN-AN-4-1', 'AN4')
dot.node('YPN-PN-102', 'PN')
dot.node('YPN-IJ-102', 'IJ')

dot.edge('YPN-CA-1', 'YPN-AN-1-1', label='YPN-SN-1-1')
dot.edge('YPN-AN-1-1', 'YPN-AN-2-1', label='YPN-SN-1-2')
dot.edge('YPN-AN-2-1', 'YPN-AN-3-1', label='YPN-SN-1-3')
dot.edge('YPN-AN-3-1', 'YPN-AN-4-1', label='YPN-SN-1-4')
dot.edge('YPN-AN-4-1', 'YPN-PN-102', label='FIber')
dot.edge('YPN-PN-102', 'YPN-IJ-102', label='FIber')
dot.render(directory=r'D:\SLD-diagram\doctest-output', view=True)

but it gives following error.

**failed to execute 'dot', make sure the graphviz executables are on your systems' path**

how to resolve this?

CodePudding user response:

Sadly common problem, you also need to install the "real" Graphviz (go here: https://www.graphviz.org/download/)
Also, see I'm getting this issue when trying to run the code I found on GitHub. Pydot and graphivz are installed but still getting this error

  • Related