我正在使用Python通过pydot.Dot创建图形。 当我想将图形写入PNG时,我使用pydot.Dot.write_png(...)。 不幸的是,它在寻找graphviz的阶段失败了(在一个名为find_graphviz的函数中)。Python graphviz - pydot.Dot.write_png does not work(windows)
我试着将它安装为一个软件,但我看不到它是如何导入到Python的。
任何人都遇到过这个问题?
谢谢。
我正在使用Python通过pydot.Dot创建图形。 当我想将图形写入PNG时,我使用pydot.Dot.write_png(...)。 不幸的是,它在寻找graphviz的阶段失败了(在一个名为find_graphviz的函数中)。Python graphviz - pydot.Dot.write_png does not work(windows)
我试着将它安装为一个软件,但我看不到它是如何导入到Python的。
任何人都遇到过这个问题?
谢谢。
尝试手动将Graphviz \ bin文件夹添加到您的系统PATH。
>>> import pydot
>>> pydot.find_graphviz()
{'dot': 'C:\\Program Files (x86)\\Graphviz 2.28\\bin\\dot.exe'} #...
>>> print pydot.find_graphviz.__doc__
"""
Locate Graphviz's executables in the system.
Tries three methods:
First: Windows Registry (Windows only)
This requires Mark Hammond's pywin32 is installed.
Secondly: Search the path
It will look for 'dot', 'twopi' and 'neato' in all the directories
specified in the PATH environment variable.
Thirdly: Default install location (Windows only)
It will look for 'dot', 'twopi' and 'neato' in the default install
location under the "Program Files" directory.
It will return a dictionary containing the program names as keys
and their paths as values.
If this fails, it returns None.
"""
即使在将Graphviz添加到我的PATH后,它仍然无法工作。我最终进入了pydot.py文件,并注释掉find_graphviz一切(),并在该行写:
`return {'dot': 'C:\\Program Files\\graphviz-2.38\\bin\\dot.exe'}`
这就是我点文件的位置,你可能有它在不同的位置。
谢谢。我这样做了,但是我仍然在注册阶段出现错误,即它看起来像是在注册表中没有找到它时发生的错误,但是没有继续搜索路径: #error:(2 ,'RegOpenKeyEx','系统找不到指定的文件')# – yoki 2013-05-08 20:36:10
好的 - 我在pydot.py的第432行添加了“False”,这样它就会跳过注册表部分并转到路径方法。 – yoki 2013-05-09 05:31:47