How to run neato from pygraphviz on Windows

后端 未结 4 1286
粉色の甜心
粉色の甜心 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:38

    I had the same problem. Here's what I did in case anyone else is struggling to get pygraphvis working on Windows.

    First off, I installed graphviz. I tried to install pygraphvis thrugh pip, but it refused to work. Eventually, I found the unofficial Windows binaries, so I installed that. Importing the module now works, but calling G.layout() led to the above error.

    Calling neato -V worked, so it was on my PATH. I figured out that the problem was that python was running in a command prompt that was created prior to installing pygraphvis, so PATH wasn't updated. Restarting the command prompt fixed this, but led to a new error, something about C:\Program not being a valid command.

    I figured that pygraphvis was probably failing to quote the path correctly, meaning it cuts off at the space in Program Files. I solved the problem by symlinking it to a path without spaces.

    mklink /d C:\ProgramFilesx86 "C:\Program Files (x86)"
    

    Note that this must be run in admin mode. You can do it by going to the start menu, typing in cmd, and then hitting Ctrl+shift+enter.

    After this, I edited my PATH to refer to the symlink, restarted cmd, and everything worked.

提交回复
热议问题