Python 安装 Graphviz 2.38 后出现“RuntimeError:确保 Graphviz 可执行文件在您的系统路径上”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/35064304/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"RuntimeError: Make sure the Graphviz executables are on your system's path" after installing Graphviz 2.38
提问by liga810
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
我下载了Graphviz 2.38
MSI版本并安装在文件夹下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
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.
我试图放入"C:\Python34\bin\dot.exe"
系统的路径,但它没有用,我什至创建了一个"GRAPHVIZ_DOT"
带有 value的新环境变量"C:\Python34\bin\dot.exe"
,但仍然无法正常工作。我尝试卸载 Graphviz 和pip uninstall graphviz
,然后重新安装它并再次安装 pip,但没有任何效果。
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?
有没有人有任何经验?
回答by JessieB
Just add below to your Environmental Variable(system) PATHon Windows
只需将以下添加到 Windows 上的环境变量(系统)PATH
C:\Program Files (x86)\Graphviz2.38\bin
there, you can find .exefiles
C:\Program Files (x86)\Graphviz2.38\bin
在那里,您可以找到 .exe文件
If not work
如果不工作
Find Graphviz2.38/binfolder in your Program Filesnot in python lib
在你的程序文件中而不是在python lib 中找到Graphviz2.38/bin文件夹
Then, add to your PATH
然后,添加到您的PATH
It's important to find a folder where .exe files exist
找到存在 .exe 文件的文件夹很重要
回答by nono
I had the same issue on Linux with Jupyter.
我在使用 Jupyter 的 Linux 上遇到了同样的问题。
To solve it I've added the dot library to python sys.path
为了解决它,我将点库添加到 python sys.path
First: check if dot
is installed,
第一:检查是否dot
安装,
Then:
find his path whereis dot
-> /local/notebook/miniconda2/envs/ik2/bin/dot
然后:
找到他的路径whereis dot
-> /local/notebook/miniconda2/envs/ik2/bin/dot
Finally in python script : sys.path.append("/local/notebook/miniconda2/envs/ik2/bin/dot")
最后在 python 脚本中: sys.path.append("/local/notebook/miniconda2/envs/ik2/bin/dot")
回答by Rouzbeh
This one solved the problem for me on MAC:
这个解决了我在 MAC 上的问题:
brew install graphviz
回答by x2yline
First, you should use pip install, and then download another package in http://www.graphviz.org/Download_windows.phpand add the install location into the environmental path, then it works.
首先,您应该使用pip install,然后在http://www.graphviz.org/Download_windows.php下载另一个包 并将安装位置添加到环境路径中,然后它就可以工作了。
回答by kame
You should install the graphviz package in your system (not just the python package). On Ubuntuyou should try:
你应该在你的系统中安装 graphviz 包(不仅仅是 python 包)。在Ubuntu 上你应该尝试:
sudo apt-get install graphviz
回答by skyscraper
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 packageusing 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.
我在 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 时,我仍然收到错误消息。
I had to add the path /usr/local/bin in PyCharm options, as recommended in the answer to this questionto resolve the problem.
我必须在 PyCharm 选项中添加路径 /usr/local/bin ,如此问题的答案中建议的那样来解决问题。
回答by Leighton
OSX Sierra, Python 2.7, Graphviz 2.38
OSX Sierra、Python 2.7、Graphviz 2.38
Using pip install graphviz
and conda install graphviz
BOTH resolves the problem.
使用pip install graphviz
and conda install graphviz
BOTH 可以解决问题。
pip
only gets path problem same as yours and conda
only gets import error.
pip
只会得到和你一样的路径问题,conda
只会得到导入错误。
回答by Jyotsna_b
For Windows:
对于 Windows:
- Install windows package from: https://graphviz.gitlab.io/_pages/Download/Download_windows.html
- Install python
graphviz
package - Add
C:\Program Files (x86)\Graphviz2.38\bin
to User path - Add
C:\Program Files (x86)\Graphviz2.38\bin\dot.exe
to System Path
- 从以下位置安装 windows 包:https: //graphviz.gitlab.io/_pages/Download/Download_windows.html
- 安装python
graphviz
包 - 添加
C:\Program Files (x86)\Graphviz2.38\bin
到用户路径 - 添加
C:\Program Files (x86)\Graphviz2.38\bin\dot.exe
到系统路径
This worked for me!
这对我有用!
回答by Aprameyo Roy
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.
在 Windows 中,只需在开头添加这两行,其中'D:/Program Files (x86)/Graphviz2.38/bin/'替换为您的 bin 文件所在的地址。
That solves the problem.
这解决了问题。
回答by ajayramesh
Try conda install graphviz
. I had the same problem, I resolved it by mentioned command in MacOS.
试试conda install graphviz
。我遇到了同样的问题,我通过 MacOS 中提到的命令解决了它。