Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/320.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法创建png文件以使用Graphviz(Python)绘制决策树_Python_Graphviz_Pydot_Pydotplus - Fatal编程技术网

无法创建png文件以使用Graphviz(Python)绘制决策树

无法创建png文件以使用Graphviz(Python)绘制决策树,python,graphviz,pydot,pydotplus,Python,Graphviz,Pydot,Pydotplus,运行.py文件时,在尝试创建以前创建的PNG文件时,我收到此错误 pydotplus.graphviz.InvocationException: Program terminated with status: 1. stderr follows: Format: "png" not recognized. Use one of: 我没有收到更多的信息。 我已经安装了pydot、pydotplus和graphviz,但问题一直在发生 触发错误的代码是: graph = pyd

运行.py文件时,在尝试创建以前创建的PNG文件时,我收到此错误

pydotplus.graphviz.InvocationException: Program terminated with status: 1. stderr follows: Format: "png" not recognized. Use one of:
我没有收到更多的信息。 我已经安装了pydot、pydotplus和graphviz,但问题一直在发生

触发错误的代码是:

graph = pydotplus.graph_from_dot_data(dot_data.getvalue())  
graph.write_png(filename)
通过观察文件系统,我可以看到该文件已创建,但有0Kb,无法打开。所以,这篇文章可能并不成功

有什么建议吗

编辑:已解决。


必须重新安装Graphviz,在Windows中(手动)设置环境变量,重新启动计算机并创建映像。

能否在Anaconda提示符中尝试此操作:

conda install pydotplus

我遇到了同样的问题,运行这个命令为我解决了这个问题。我之前使用的是pip安装,这似乎与Jupyter有冲突。

必须重新安装Graphviz,在Windows中(手动)设置环境变量,重新启动计算机,然后创建映像。