问题描述:在调用Graphviz的Source类画图时,报错信息如下图所示:
1). FileNotFoundError: [WinError 2] 系统找不到指定的文件。
2). graphviz.backend.ExecutableNotFound: failed to execute ['dot', '-Tpng', '-O', 'test.gv'], make sure the Graphviz executables are on your systems' PATH

解决方法:
输入命令import graphviz返回正常,表示python 3.6中已安装graphviz.
根据参考文献1中的提示表明不仅需要在python中成功安装graphviz,还要在系统中安装graphviz,并在系统路径里添加配置(控制面板——》系统——》高级系统设置——》系统属性——》高级——》环境变量——》系统变量——》Path中添加C:\Program Files (x86)\Graphviz2.38\bin;)。
如果是Ubuntu系统,可使用命令 sudo apt-get install graphviz 安装;
如果是Windows系统,则去官网下载安装包,目前稳定版是graphviz-2.38.msi或graphviz-2.38.zip;
如果是Mac系统,可以通过Homebrew安装。
参考文献:
本文详细介绍了在不同操作系统(Windows、Ubuntu、Mac)下安装Graphviz的方法,以及如何在Python环境中正确配置Graphviz,确保绘图功能正常运行。特别强调了在系统路径中添加Graphviz可执行文件路径的重要性。
1万+





