How to run neato from pygraphviz on Windows

后端 未结 4 1279
粉色の甜心
粉色の甜心 2020-12-30 09:50

I am trying to use pygraphviz and networkx in python (v 2.7) to create a network map. I found a script that looks very useful on stackoverflow:

import netwo         


        
4条回答
  •  南方客
    南方客 (楼主)
    2020-12-30 10:48

    There is probably more than one cause for this error, but if it is caused by a missing path to the graphviz modules [neato,dot,twopi,circo,fdp,nop], then there is one hack that worked for me. I'm currently asking what the correct solution is, but you can use this

    if  not 'C:\\Program Files (x86)\\Graphviz2.38\\bin' in os.environ["PATH"]: 
        os.environ["PATH"] += os.pathsep + 'C:\\Program Files (x86)\\Graphviz2.38\\bin' 
    

    at the beginning of your script. To generalize, if your graphviz files are saved somewhere else:

    graph_path='your_bin_folder_path'
        if  not graph_path in os.environ["PATH"]: 
            os.environ["PATH"] += os.pathsep + graph_path
    

    In particular, this worked on windows 10, using anaconda navigator and python version 3.7.

提交回复
热议问题