安装GraphViz和pydotplus后,未找到IPython 3.5 GraphViz的可执行文件

2024-04-27 03:37:15 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经安装了graphviz 2.38.0-4。此错误消息仍显示:

C:\Users\username\AppData\Local\Continuum\Anaconda3\lib\site- packages\pydotplus\graphviz.py in create(self, prog, format)
   1958             if self.progs is None:
   1959                 raise InvocationException(
-> 1960                     'GraphViz\'s executables not found')
   1961 
   1962         if prog not in self.progs:

InvocationException: GraphViz's executables not found

我试过这里的方法:Graphviz's executables are not found (Python 3.4) 仍然无法解决问题。在


Tags: inself消息if错误usernamenotusers
1条回答
网友
1楼 · 发布于 2024-04-27 03:37:15

我也遇到了同样的问题。结果发现,Anaconda上的graphviz(至少在Windows上)与PyPI上的graphviz包不一样,也就是说,它不是graphviz的Python包装器,而是graphviz二进制文件本身。Conda将二进制文件安装在“Library\bin”文件夹中(例如,在我的例子中是“C:\Anconda3\Library\bin”)。通常情况下,“Library\bin”位于系统路径上。但是anaconda graphviz包将graphviz二进制文件放在它们自己的子目录“Library\bin\graphviz”中—有一个批处理文件点蝙蝠,在“Library\bin”中将调用重定向到“Library\bin\graphviz”\点.exe". 所以默认情况下,“twopi”之类的二进制文件不在路径上。但至少pydotplus(我测试过的唯一一个)希望它们是;或者它在Windows注册表中寻找“遗留”Graphviz安装,如果失败,则在默认安装位置(在%PROGRAMFILES%下)。在

所以我看到两种解决方案:要么直接从graphviz.com安装Graphviz。因为我想保留通过“conda”更新“graphviz”的功能,所以我使用pydotplus的“set_graphviz_executables”来覆盖到可执行文件的路径。就我所理解的,每一张图我都要重做:

import os

def conda_fix(graph):
        path = os.path.join(sys.base_exec_prefix, "Library", "bin", "graphviz")
        paths = ("dot", "twopi", "neato", "circo", "fdp")
        paths = {p: os.path.join(path, "{}.exe".format(p)) for p in paths}
        graph.set_graphviz_executables(paths)

graph = pydotplus.graph_from_data(data)
conda_fix(graph)
Image(graph.create_png())

相关问题 更多 >