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

有人有经验吗?


当前回答

你可以在Anaconda提示符中使用以下命令:

Conda Install python-graphviz

确保在Anaconda提示符中安装pm4py:

PIP安装pm4py

最后,你必须尝试使用Anaconda提示符运行你的python代码。

其他回答

您应该在系统中安装graphviz包(而不仅仅是python包)。在Ubuntu上,你应该尝试:

sudo apt-get install graphviz
import os
os.environ["PATH"] += os.pathsep + "/Macintosh HD⁩/anaconda3⁩/lib⁩/⁨python3.7⁩/site-packages⁩/sphinx⁩/templates⁩/graphviz"

这为我解决了MAC上的PATH问题!

步骤1:安装Graphviz二进制文件

窗口:

从http://www.graphviz.org/download/下载Graphviz 将以下内容添加到PATH环境变量(提到已安装的graphviz版本): C:\Program Files (x86)\ Graphviz2.38\bin C:\Program Files (x86)\ Graphviz2.38\bin\dot.exe 关闭任何打开的Juypter笔记本电脑和命令提示符 重新启动Jupyter / cmd提示符并测试

Linux:

Sudo apt-get update Sudo apt-get安装graphviz 或者从http://www.graphviz.org/download/手动构建

步骤2:安装python的graphviz模块

皮普:

PIP安装graphviz

第二:

康达安装图形可视化

当我第一次安装pydot和graphviz时,它显示了错误,但下面的命令对我有用:

import os
os.environ["PATH"] += os.pathsep + r'C:\Users\vivek\Downloads\graphviz-2.44.1-win32\Graphviz\bin'

我在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点)。