我下载了Graphviz 2.38 MSI版本,安装在C:\Python34文件夹下,然后运行pip安装Graphviz,一切顺利。在系统路径中我添加了C:\Python34\bin。当我试图运行一个测试脚本,在行filename= .render(filename='test'),我得到了一个消息

 RuntimeError: failed to execute ['dot', '-Tpdf', '-O', 'test'], make sure the Graphviz executables are on your systems' path

我尝试将“C:\Python34\bin\dot.exe”放在系统路径中,但它不起作用,我甚至创建了一个新的环境变量“GRAPHVIZ_DOT”,其值为“C:\Python34\bin\dot.exe”,仍然不起作用。我尝试卸载Graphviz和pip uninstall Graphviz,然后重新安装它和pip install,但没有任何工作。

整个回溯消息是:

Traceback (most recent call last):
  File "C:\Python34\lib\site-packages\graphviz\files.py", line 220, in render
    proc = subprocess.Popen(cmd, startupinfo=STARTUPINFO)
  File "C:\Python34\lib\subprocess.py", line 859, in __init__
    restore_signals, start_new_session)
  File "C:\Python34\lib\subprocess.py", line 1112, in _execute_child
    startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Documents\Kissmetrics\curves and lines\eventNodes.py", line 56, in <module>
    filename=dot.render(filename='test')
  File "C:\Python34\lib\site-packages\graphviz\files.py", line 225, in render
    'are on your systems\' path' % cmd)
RuntimeError: failed to execute ['dot', '-Tpdf', '-O', 'test'], make sure the Graphviz executables are on your systems' path

有人有经验吗?


当前回答

1.安装windows软件包:https://graphviz.gitlab.io/_pages/Download/Download_windows.html,下载msi文件

添加环境变量 2. 添加“用户路径”为“C:\Program Files (x86)\ Graphviz2.38\bin”

将C:\Program Files (x86)\ Graphviz2.38\bin\dot.exe添加到“系统路径” 重新启动你的python笔记本。

它会起作用的。

其他回答

1-首先向下下载它(图形可视化2.38)。

2-安装org.graphviz.Graphviz-2.38-graphviz-2.38。

3-现在添加“C:\Program Files (x86)\Graphviz2.38\bin”和“C:\Program Files (x86)\Graphviz2.38\bin\dot.exe”到这样的路径 注意:在Windows 8中必须使用;C:\程序文件;D:\用户;E:\文件\

1) Graphviz -在系统的特定位置下载解压缩(pip在windows中不起作用),并在每个程序中手动设置的路径(' set environment variables in windows ' OR)中包含bin文件夹

import os
os.environ["PATH"] += os.pathsep + 'C:/GraphViz/bin'

2)然后将模型放到图中

clf = xgb.train(params, d_train, 1000, evals=evallist, early_stopping_rounds=10)
xgb.plot_tree(clf)
plt.rcParams['figure.figsize'] = [50, 10]
plt.show()

我在macOS Catalina 10.15.3上,我有一个类似的错误:ExecutableNotFound: failed to execute ['dot', '-Tsvg'],请确保Graphviz可执行文件在您的系统的PATH上

固定它与:

pip3安装graphviz和酿造安装graphviz

请注意,pip3安装只会返回成功消息成功安装graphviz-0.13.2,所以我们仍然需要运行brew install来获得graphviz 2.42.3(截至2020年3月10日下午6点)。

我在Mac OS (El Capitan)上使用PyCharm IDE时也遇到了同样的错误信息。 我已经使用brew安装了Graphviz,正如RZK的回答中推荐的那样,并使用PyCharm安装了Graphviz python包(我可以通过在终端中尝试点- v并获得:点- Graphviz version 2.40.1(20161225.0304)来检查Graphviz是否正确安装)。 然而,当我试图从PyCharm调用Graphviz时,我仍然收到错误消息。

我必须在PyCharm选项中添加路径/usr/local/bin,就像在回答这个问题时建议的那样来解决这个问题。

如果你使用的不是Conda,而是普通的Python, 'brew install graphviz'可以工作。