问题:安装Graphviz 2.38后,“ RuntimeError:确保Graphviz可执行文件在系统路径上”

我下载了Graphviz 2.38MSI版本并安装在文件夹下C:\Python34,然后运行pip install Graphviz,一切顺利。在系统的路径中,我添加了C:\Python34\bin。在尝试在线运行测试脚本时filename=dot.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"带有value 的新环境变量"C:\Python34\bin\dot.exe",但仍然没有用。我尝试卸载Graphviz和pip uninstall graphviz,然后重新安装并再次进行pip安装,但是没有任何效果。

整个回溯消息是:

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

有人有经验吗?

I downloaded Graphviz 2.38 MSI version and installed under folder C:\Python34, then I run pip install Graphviz, everything went well. In system’s path I added C:\Python34\bin. When I tried to run a test script, in line filename=dot.render(filename='test'), I got a message

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

I tried to put "C:\Python34\bin\dot.exe" in system’s path, but it didn’t work, and I even created a new environment variable "GRAPHVIZ_DOT" with value "C:\Python34\bin\dot.exe", still not working. I tried to uninstall Graphviz and pip uninstall graphviz, then reinstall it and pip install again, but nothing works.

The whole traceback message is:

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

Does anybody have any experience with it?


回答 0

import os
os.environ["PATH"] += os.pathsep + 'D:/Program Files (x86)/Graphviz2.38/bin/'

在Windows中,只需在开头添加这两行,其中“ D:/ Program Files(x86)/Graphviz2.38/bin/”将替换为bin文件所在的地址。

那解决了问题。

import os
os.environ["PATH"] += os.pathsep + 'D:/Program Files (x86)/Graphviz2.38/bin/'

In windows just add these 2 lines in the beginning, where ‘D:/Program Files (x86)/Graphviz2.38/bin/’ is replaced by the address of where your bin file is.

That solves the problem.


回答 1

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

sudo apt-get install graphviz

You should install the graphviz package in your system (not just the python package). On Ubuntu you should try:

sudo apt-get install graphviz

回答 2

这是我在MAC上为我解决的问题

  brew install graphviz

This one solved the problem for me on MAC:

  brew install graphviz

回答 3

对于Windows:

  1. 从以下位置安装Windows软件包:https : //graphviz.gitlab.io/_pages/Download/Download_windows.html
  2. 安装python graphviz
  3. 添加C:\Program Files (x86)\Graphviz2.38\bin到用户路径
  4. 添加C:\Program Files (x86)\Graphviz2.38\bin\dot.exe到系统路径

这对我有用!

For Windows:

  1. Install windows package from: https://graphviz.gitlab.io/_pages/Download/Download_windows.html
  2. Install python graphviz package
  3. Add C:\Program Files (x86)\Graphviz2.38\bin to User path
  4. Add C:\Program Files (x86)\Graphviz2.38\bin\dot.exe to System Path

This worked for me!


回答 4

尝试使用:

conda install python-graphviz

如果使用,graphviz可执行文件与conda目录位于不同的路径pip install graphviz

Try using:

conda install python-graphviz

The graphviz executable sit on a different path from your conda directory, if you use pip install graphviz.


回答 5

OSX Sierra,Python 2.7,Graphviz 2.38

使用pip install graphvizconda install graphviz解决了该问题。

pip只得到与您相同的路径问题,并且conda只得到导入错误。

OSX Sierra, Python 2.7, Graphviz 2.38

Using pip install graphviz and conda install graphviz BOTH resolves the problem.

pip only gets path problem same as yours and conda only gets import error.


回答 6

只需将以下内容添加到 Windows上的环境变量(系统)路径

C:\ Program档案(x86)\ Graphviz2.38 \ bin

在那里,您可以找到 .exe文件

如果不行

在您的程序文件中而不是python lib中找到Graphviz2.38 / bin文件夹

然后,添加到您的PATH

找到存在.exe文件的文件夹很重要

Just add below to your Environmental Variable(system) PATH on Windows

C:\Program Files (x86)\Graphviz2.38\bin

there, you can find .exe files

If not work

Find Graphviz2.38/bin folder in your Program Files not in python lib

Then, add to your PATH

It’s important to find a folder where .exe files exist


回答 7

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

视窗:

  1. http://www.graphviz.org/download/下载Graphviz
  2. 在下面添加到PATH环境变量中(提及已安装的graphviz版本):
    • C:\ Program档案(x86)\ Graphviz2.38 \ bin
    • C:\ Program Files(x86)\ Graphviz2.38 \ bin \ dot.exe
  3. 关闭所有打开的Juypter笔记本和命令提示符
  4. 重新启动Jupyter / cmd提示并测试

Linux:

  1. sudo apt-get更新
  2. 须藤apt-get install graphviz
  3. 或从http://www.graphviz.org/download/手动构建

步骤2:为Python安装graphviz模块

点:

  • 点安装graphviz

康达:

  • 康达安装graphviz

Step 1: Install Graphviz binary

Windows:

  1. Download Graphviz from http://www.graphviz.org/download/
  2. Add below to PATH environment variable (mention the installed graphviz version):
    • C:\Program Files (x86)\Graphviz2.38\bin
    • C:\Program Files (x86)\Graphviz2.38\bin\dot.exe
  3. Close any opened Juypter notebook and the command prompt
  4. Restart Jupyter / cmd prompt and test

Linux:

  1. sudo apt-get update
  2. sudo apt-get install graphviz
  3. or build it manually from http://www.graphviz.org/download/

Step 2: Install graphviz module for python

pip:

  • pip install graphviz

conda:

  • conda install graphviz

回答 8

尝试conda install graphviz。我有同样的问题,我通过MacOS中提到的命令解决了。

Try conda install graphviz. I had the same problem, I resolved it by mentioned command in MacOS.


回答 9

对我来说,在Windows10上使用conda install graphvizconda install python-graphviz安装GraphViz所需的路径是C:/ ProgramData / Anaconda3 / Library / bin / graphviz /。即添加

import os
os.environ["PATH"] += os.pathsep + 'C:/ProgramData/Anaconda3/Library/bin/graphviz/'

为我解决了这个问题。

Using conda install graphviz and conda install python-graphviz to install GraphViz on Windows10 the path needed was C:/ProgramData/Anaconda3/Library/bin/graphviz/ for me. I.e. adding

import os
os.environ["PATH"] += os.pathsep + 'C:/ProgramData/Anaconda3/Library/bin/graphviz/'

solved the issue for me.


回答 10

conda install python-graphviz

对于Windows,请安装Python Graphviz,它将在路径中包含可执行文件。

conda install python-graphviz

For Windows, install the Python Graphviz which will include the executables in the path.


回答 11

在Ubuntu Linux上,这为我解决了问题:

pip install graphviz
sudo apt-get install graphviz

conda install -c conda-forge graphviz如果使用Anaconda,也可以尝试代替pip。

On Ubuntu Linux this solved it for me:

pip install graphviz
sudo apt-get install graphviz

You could also try conda install -c conda-forge graphviz instead of pip if using Anaconda.


回答 12

在为自己解决此问题时,我使用了此GitHub教程,该教程分析了导致此问题的原因。如果我们在两行之间阅读,它说它需要系统以及python graph viz。除了conda install,我们还需要运行:

conda install -c conda-forge python-graphviz

然后重启内核;它就像一个魅力。

When solving this issue for myself, I used this GitHub tutorial, which analysed the cause of this issue. If we read in between the lines, it says it needs system as well as python graph viz. In addition to conda install, we would need to run:

conda install -c conda-forge python-graphviz

Then restart the kernel; it works like a charm.


回答 13

1)Graphviz –在系统的特定位置下载解压缩文件(pip在Windows中不起作用),并在每个程序中手动设置的路径中包含bin文件夹(“在Windows中设置环境变量”或)

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()

1) Graphviz – download unzip in a particular place in the system (pip does not work in windows ) and include the bin folder in the path (‘set environment variables in windows’ OR) set manually in each program

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

2) Then put the model to plot

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()

回答 14

安装软件包后(如果尚未安装,请链接),将dot.exe的路径添加为新的系统变量。

默认路径是:

C:\ Program Files(x86)\ Graphviz2.38 \ bin \ dot.exe

在此处输入图片说明

After you’ve installed the package (link if you haven’t), add the path to dot.exe as a new system variable.

Default path is:

C:\Program Files (x86)\Graphviz2.38\bin\dot.exe

enter image description here


回答 15

我在使用Jupyter的Linux上遇到了相同的问题。

为了解决这个问题,我已经将点库添加到python sys.path中

首先:检查是否dot已安装,

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

最后在python脚本中:sys.path.append(“ / local / notebook / miniconda2 / envs / ik2 / bin / dot”)

I had the same issue on Linux with Jupyter.

To solve it I’ve added the dot library to python sys.path

First: check if dot is installed,

Then:
find his path whereis dot -> /local/notebook/miniconda2/envs/ik2/bin/dot

Finally in python script : sys.path.append(“/local/notebook/miniconda2/envs/ik2/bin/dot”)


回答 16

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

First, you should use pip install, and then download another package in http://www.graphviz.org/Download_windows.php and add the install location into the environmental path, then it works.


回答 17

在Mac OS(El Capitan)上,我使用PyCharm IDE遇到了相同的错误消息。我已按照RZK的答案中的建议使用brew安装了Graphviz,并使用PyCharm 安装了graphviz python软件包(我可以通过dot -V在终端中尝试并获取以下内容来检查Graphviz是否已正确安装:dot - graphviz version 2.40.1 (20161225.0304))。但是,当尝试从PyCharm调用Graphviz时,我仍然收到错误消息。

我必须按照此问题的答案中的建议,在PyCharm选项中添加路径/ usr / local / bin 。

I had the same error message on Mac OS (El Capitan), using the PyCharm IDE. I had installed Graphviz using brew, as recommended in RZK’s answer, and installed the graphviz python package using PyCharm (I could check Graphviz was installed correctly by trying dot -V in a terminal and getting: dot - graphviz version 2.40.1 (20161225.0304)). Yet I was still getting the error message when trying to call Graphviz from PyCharm.

I had to add the path /usr/local/bin in PyCharm options, as recommended in the answer to this question to resolve the problem.


回答 18

这显示了一些路径问题:

pip install graphviz

所以这对我有用:

sudo apt-get install graphviz

This is showing some path issue:

pip install graphviz

So this worked for me:

sudo apt-get install graphviz

回答 19

我在macOS Catalina 10.15.3上,并且遇到了类似的错误: ExecutableNotFound: failed to execute ['dot', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH

使用以下方法修复了该问题:

pip3 install graphvizbrew install graphviz

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

I’m on macOS Catalina 10.15.3, and I had a similar error: ExecutableNotFound: failed to execute ['dot', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH

Fixed it with:

pip3 install graphviz AND brew install graphviz

Note the pip3 install will only return the success message Successfully installed graphviz-0.13.2 so we still need to run brew install to get graphviz 2.42.3 (as of 10 Mar 2020, 6PM).


回答 20

对于没有root权限并因此无法sudo按照其他答案中的建议使用命令的Linux用户…

首先,通过以下方法激活您的conda虚拟环境(如果要使用):

source activate virtual-env-name

然后安装graphviz,即使您已经使用pip完成了它:

conda install graphviz

然后复制以下命令的结果:

whereis dot

就我而言,其输出为:

/home/nader/anaconda2/bin/dot

并将其添加到您的PATH变量中。只需运行以下命令

nano ~/.bashrc

并将这些行添加到打开的文件的末尾:

PATH="/home/username/anaconda2/bin/dot:$PATH"
export PATH

现在按Ctrl+ O,然后Ctrl+ X保存并退出。

现在应该解决问题。

Pycharm用户,请注意:Pycharm并不总是看到与您的终端相同的PATH变量。该解决方案不适用于Pycharm以及其他IDE。但是您可以通过添加以下代码行来解决此问题:

os.environ["PATH"] += os.pathsep + '/home/nader/anaconda2/bin'

到您的python程序。不要忘记

import os

首先:)

编辑:如果您不想使用conda,您仍然可以没有任何root权限的情况下从此处安装graphviz ,并将bin文件夹添加到PATH变量中。我没有测试。

For Linux users who don’t have root access and hence can’t use sudo command as suggested in other answers…

First, activate your conda virtual-environment (if you want to use one) by:

source activate virtual-env-name

Then install graphviz, even if you have already done it using pip:

conda install graphviz

then copy the result of the following command:

whereis dot

In my case, its output is:

/home/nader/anaconda2/bin/dot

and add it to your PATH variable. Just run the command below

nano ~/.bashrc

and add these lines to the end of the opened file:

PATH="/home/username/anaconda2/bin/dot:$PATH"
export PATH

now press Ctrl+O and then Ctrl+X to save and exit.

Problem should be solved by now.

Pycharm users, please note: Pycharm does not always see the PATH variable the same as your terminal. This solution does not work for Pycharm, and maybe other IDEs. But you can fix this by adding this line of code:

os.environ["PATH"] += os.pathsep + '/home/nader/anaconda2/bin'

to your python program. Do not forget to

import os

first :)

Edit: If you don’t want to use conda, you can still install graphviz from here without any root permissions and add the bin folder to your PATH variable. I didn’t test this.


回答 21

1.从以下位置安装Windows软件包:https ://graphviz.gitlab.io/_pages/Download/Download_windows.html 并下载msi文件

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

  1. 将C:\ Program Files(x86)\ Graphviz2.38 \ bin \ dot.exe添加到系统路径

  2. 重新启动您的python笔记本。

会的。

1.install windows package from: https://graphviz.gitlab.io/_pages/Download/Download_windows.html and download msi file

Add in Environmental variables 2. Add C:\Program Files (x86)\Graphviz2.38\bin to User path

  1. Add C:\Program Files (x86)\Graphviz2.38\bin\dot.exe to System Path

  2. Restart your python notebook.

It will work.


回答 22

graphviz添加到系统路径

  1. Windows-编辑系统环境变量。
  2. 选择环境变量。
  3. 选择路径-新建
  4. 添加graphviz的路径

例如:C:\ Users \ AppData \ Local \ Continuum \ anaconda3 \ Library \ bin \ graphviz

Add graphviz to the System Path

  1. Windows – Edit the System Environment Variables.
  2. Choose Environment Variables.
  3. Select Path – New
  4. Add the Path of graphviz

Ex: C:\Users\AppData\Local\Continuum\anaconda3\Library\bin\graphviz


回答 23

OS Mojave 10.14。,Python 3.6

使用pip install graphviz在终端上有很好的反馈,但是当我尝试在Jupyter笔记本中绘制图形时导致使用此错误。然后brew install graphviz,我运行,这在终端中给出了错误。然后我跑conda install graphviz了,图开始工作了。

来自@Leighton的评论:pip仅会遇到与您相同的路径问题,而conda仅会导致导入错误。

OS Mojave 10.14., Python 3.6

Using pip install graphviz had good feedback in terminal, but lead to this error when I tried to make a graph in a Jupyter notebook. I then ran brew install graphviz, which gave an error in terminal. Then I ran conda install graphviz and the graph worked.

From @Leighton’s comment: pip only gets path problem same as yours and conda only gets import error.


回答 24

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

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

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

This solved the PATH issue on MAC for me!


回答 25

如果您不是使用Conda而是使用Vanilla Python,则“ brew install graphviz”有效。

If you are not using Conda but vanilla Python, ‘brew install graphviz’ works.


回答 26

#Write this on anaconda prompt in admin mode
conda install -c anaconda graphviz
conda install -c conda-forge python-graphviz
conda install -c conda-forge/label/broken python-graphviz
conda install -c conda-forge/label/cf201901 python-graphviz
conda install -c conda-forge/label/cf202003 python-graphviz

#check dot -v in window's cmd prompt
C:\WINDOWS\system32>dot -V
dot - graphviz version 2.38.0 (20140413.2041)
(this means graphviz installed successfully)

#Add path to sys and user eve variables
PATH
C:\Anaconda3\pkgs\graphviz-2.38-hfd603c8_2\Library\bin
(search bin folder of graphviz and then copy n paste path in env variables)

#Re-run all cmds in jyupter notebook
#if error occurs (less chances)
#then 
#Restart anaconda and again run all cmds in jyupter notebook
eg.
import graphviz as gp
with open("tree.dot") as f:
    dot_read=f.read()
display(gp.Source(dot_read))
#Write this on anaconda prompt in admin mode
conda install -c anaconda graphviz
conda install -c conda-forge python-graphviz
conda install -c conda-forge/label/broken python-graphviz
conda install -c conda-forge/label/cf201901 python-graphviz
conda install -c conda-forge/label/cf202003 python-graphviz

#check dot -v in window's cmd prompt
C:\WINDOWS\system32>dot -V
dot - graphviz version 2.38.0 (20140413.2041)
(this means graphviz installed successfully)

#Add path to sys and user eve variables
PATH
C:\Anaconda3\pkgs\graphviz-2.38-hfd603c8_2\Library\bin
(search bin folder of graphviz and then copy n paste path in env variables)

#Re-run all cmds in jyupter notebook
#if error occurs (less chances)
#then 
#Restart anaconda and again run all cmds in jyupter notebook
eg.
import graphviz as gp
with open("tree.dot") as f:
    dot_read=f.read()
display(gp.Source(dot_read))

回答 27

尝试在anaconda提示中一一键入以下代码。

这对我有用。

资料来源:https : //anaconda.org/conda-forge/python-graphviz

conda install -c conda-forge python-graphviz
conda install -c conda-forge/label/broken python-graphviz
conda install -c conda-forge/label/cf201901 python-graphviz
conda install -c conda-forge/label/cf202003 python-graphviz 

try typing the following code in anaconda prompt one by one.

this worked for me.

Source: https://anaconda.org/conda-forge/python-graphviz

conda install -c conda-forge python-graphviz
conda install -c conda-forge/label/broken python-graphviz
conda install -c conda-forge/label/cf201901 python-graphviz
conda install -c conda-forge/label/cf202003 python-graphviz 

回答 28

尝试在python import sys中做到这一点!conda install –yes –prefix {sys.prefix} graphviz import graphviz

trying doing this in python import sys !conda install –yes –prefix {sys.prefix} graphviz import graphviz


声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。