python AttributeError: 'Digraph' object has no attribute 'splitlines'

问题遇到的现象和发生背景

使用graphviz可视化lightgbm树并保存为pdf,出现下述错误:
AttributeError: 'Digraph' object has no attribute 'splitlines'

用代码块功能插入代码,请勿粘贴截图
    def getViewer(self, model_lgb):
        #  输出决策树  #
        dot_data = lgb.create_tree_digraph(model_lgb, tree_index=1, show_info=['split_gain'])  # 画决策树
        graph = graphviz.Source(dot_data)
        now = gt.timeTitle()
        graph.view('view' + now, directory='D:/Personality/paper/矿物识别/分析结果/决策树')

运行结果及报错内容

img

我的解答思路和尝试过的方法

出现问题的地方时graph.view()函数这一步,但不知道为什么,我尝试过使用matplotlib画决策树可以,但是graphviz就不行,说是没有splitlines。