美文网首页
2018-08-23 Jupyter中安装Graphviz

2018-08-23 Jupyter中安装Graphviz

作者: 阿康666666 | 来源:发表于2018-08-23 00:36 被阅读747次

学习决策树的时候,需要用到Graphivz库,具体代码如下:

import mglearn
mglearn.plots.plot_animal_tree()

然鹅,报了一长串的错误信息:

ExecutableNotFound: failed to execute ['dot', '-Tpng', '-O', 'tmp'], make sure the Graphviz executables are on your systems' PATH

网上查了好久总算找到解决方法了:
1.官网下载Graphviz的msi安装包,安装。
2.将......\Graphviz2.38\bin作为系统变量添加到系统环境变量的Path中。
3.重新运行代码,发现仍然提示错误。因为仍需在代码中引入path路径

import os
os.environ["PATH"] += os.pathsep + 'D:/Graphviz2.38/bin'
  • 最终代码:
import mglearn
import os
os.environ["PATH"] += os.pathsep + 'D:/Graphviz2.38/bin'

mglearn.plots.plot_animal_tree()
  • 输出结果


    image.png

相关文章

网友评论

      本文标题:2018-08-23 Jupyter中安装Graphviz

      本文链接:https://www.haomeiwen.com/subject/yuwuiftx.html