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:[WinError2]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.
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/'
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:
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'
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.
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.
我在macOS Catalina 10.15.3上,并且遇到了类似的错误: ExecutableNotFound: failed to execute ['dot', '-Tsvg'], make sure the Graphviz executables are on your systems' PATH
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).
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:
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.
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"
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))
import pydot
graph = pydot.Dot(graph_type='graph')
for i in range(3):
edge = pydot.Edge("king", "lord%d" % i)
graph.add_edge(edge)
vassal_num = 0
for i in range(3):
for j in range(2):
edge = pydot.Edge("lord%d" % i, "vassal%d" % vassal_num)
graph.add_edge(edge)
vassal_num += 1
graph.write_png('example1_graph.png')
It prints me the error message:
Couldn't import dot_parser, loading of dot files will not be possible.
For anyone else who comes across this, it is due to the changes in pyparsing from 1.x to the 2.x release.
To install pydot using pip, first install the older version of pyparsing:
There is a new package in the pip repo called pydot2 that functions correctly with pyparsing2. I couldn’t downgrade my packages because matplotlib depends on the newer pyparsing package.
diff --git a/dot_parser.py b/dot_parser.py
index dedd61a..138d152100644--- a/dot_parser.py
+++ b/dot_parser.py
@@-25,8+25,9@@from pyparsing import __version__ as pyparsing_version
from pyparsing import( nestedExpr,Literal,CaselessLiteral,Word,Upcase,OneOrMore,ZeroOrMore,Forward,NotAny, delimitedList, oneOf,Group,Optional,Combine, alphas, nums,
restOfLine, cStyleComment, nums, alphanums, printables, empty, quotedString,-ParseException,ParseResults,CharsNotIn, _noncomma, dblQuotedString,QuotedString,ParserElement)+ParseException,ParseResults,CharsNotIn, dblQuotedString,QuotedString,ParserElement)+_noncomma ="".join([ c for c in printables if c !=","])class P_AttrList:
There are now at least 2 more versions that appear to support PyParsing-2 and Python-3:
PyDotPlus by Carlos Jenkins with a nice travis buildbot and fancy documentation. However you will need to change its folder name from site-packages\pydotplus to site-packages\pydot for it to work with existing programs that import pydot.
I had the problem again and my above solution did not work. If that is true for you and you are also using Anaconda on a Mac with El Capitan, try this:
On OSX Mavericks the following did the trick… I got the same error but at the bottom there was also a complaint that the graphviz executable was not present… I think the problem was i had installed graphviz prior to the other modules?
brew uninstall graphviz
brew install graphviz
回答 11
当其他解决方案不起作用时,这是解决探针的一种快速而肮脏的方法:
这个例子来自Ubuntu 16.04上的python 2.7。
编辑文件python2.7 / site-packages / keras / utils / visualize_util.py并注释以下代码段。
ifnot pydot.find_graphviz():raiseImportError('Failed to import pydot. You must install pydot'' and graphviz for `pydotprint` to work.')
I also met the problem and my pydot==1.0.28 while pyparsing==2.2.0. I fixed the problem by downloading the newest pydot 1.2.3(tar.gz)from google and then install it offline. When I updated the pydot in ubuntu 14.04, it said the pydot 1.0.28 is the newest version. Therefore I download from the google the 1.2.3 version.