我下载了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

有人有经验吗?


当前回答

对于windows,这两个命令适用于我,在以管理员身份运行的power shell中。

PIP安装graphviz Choco安装graphviz

其他回答

我在Linux上使用Jupyter时也遇到了同样的问题。

为了解决这个问题,我在python sys.path中添加了点库

第一:检查dot是否安装,

然后: 找到他的路径:dot -> /local/notebook/miniconda2/envs/ik2/bin/dot

最后在python脚本中: sys.path.append(“/地方/笔记本/ miniconda2 / env / ik2 / bin /点”)

首先,您应该使用pip install,然后在http://www.graphviz.org/Download_windows.php下载另一个包 并将安装位置添加到环境路径中,然后它就可以工作了。

我使用的是windows10,我尝试在程序文件中安装graphwiz并设置路径:对我不起作用

试着

conda install -c anaconda graphviz

是行不通的。

然后试着

conda install python-graphviz

它工作了,似乎我们的python编译器无法访问Graphwiz。因此python-graphwize起作用了。 PIP安装graphviz也不工作。

在为自己解决这个问题时,我使用了这个GitHub教程,它分析了这个问题的原因。如果我们从字里行间读出来,它说它需要system以及python graph viz。除了conda install之外,我们还需要运行:

conda install -c conda-forge python-graphviz

然后重新启动内核;这招很管用。

我在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,就像在回答这个问题时建议的那样来解决这个问题。