import pydotplus
操作环境:
MacBook Pro,
Python3.6.5,
Jupyter Notebook,
系统版本:Mac OS Big Sur
from IPython.display import display,Image
dot_data = tree.export_graphviz(clf,
out_file=None,
feature_names=iris_feature_name,
class_names = iris_target_name,
filled = True,
rounded = True
)
graph = pydotplus.graph_from_dot_data(dot_data)
display(Image(graph.create_png()))
执行最后一行代码是 提示
InvocationException: GraphViz's executables not found
很明显,需要安装graphviz
首先确保brew安装,brew install graphviz
附:
Mac安装brew
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"
开始执行Brew自动安装程序
['2021-06-06 11:19:39']['11.4']
https://zhuanlan.zhihu.com/p/111014448
请选择一个下载镜像,例如中科大,输入1回车。
源有时候不稳定,如果git克隆报错重新运行脚本选择源。cask非必须,有部分人需要。
1、中科大下载源 2、清华大学下载源 3、北京外国语大学下载源 4、腾讯下载源(不推荐) 5、阿里巴巴下载源(不推荐 缺少cask源)
选择2 网络问题导致失败
选择3 后续安装软件(brew install )容易异常
==> Installing dependencies for git: pcre2
==> Installing git dependency: pcre2
==> Pouring pcre2-10.37.big_sur.bottle.tar.gz
tar: Error opening archive: Failed to open '/Users/aimmon/Library/Caches/Homebrew/downloads/a4ffef1d16f544b1487c843bbf93381600366d3c365c37befc664cba85dfa603--pcre2-10.37.big_sur.bottle.tar.gz'
Error: Failure while executing; `tar --extract --no-same-owner --file /Users/aimmon/Library/Caches/Homebrew/downloads/a4ffef1d16f544b1487c843bbf93381600366d3c365c37befc664cba85dfa603--pcre2-10.37.big_sur.bottle.tar.gz --directory /private/tmp/d20210606-18464-1u8c5v5` exited with 1. Here's the output:
选择1(个人推荐)
最后运行成功