【Python学习笔记】pydot与GraphViz牵手失败的解决方案(base anaconda)

感谢:https://blog.csdn.net/weixin_38516136/article/details/78282201 这篇给出了一段demo(如下),顺利输出图像表示安装成功。

import pydot
from PIL import Image
edg = [(1,2), (1,3), (1,4) , (3,4)]
g=pydot.graph_from_edges(edg)
g.write_jpeg('graph.jpg', prog = 'dot')
img = Image.open('graph.jpg')
img.show()

因为不管如何尝试卸载安装、各种顺序安装、都还是会提示OSError:

‘pydot’ failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/) and ensure that its executables are in the $PATH.

场面一度很尴尬,因为pydot和GraphViz都安装了并且GraphViz也已经添加到系统环境变量。且GraphViz也pip了。也不存在python2.7和python3的问题。

撇开以上各种可能之后,找到了另一种方式:直接用conda安装:

conda install graphviz

然后重新启动一下。

 

所以这一篇之所以没有放在pip集合里,就是因为pip一直fail了。

你可能感兴趣的:(Python之路,pydot,graphviz,anaconda,conda)