找不到GraphViz的可执行文件-通过pip安装graphViz后为什么没有安装可执行文件? [英] GraphViz's executables not found - Why are there no executables installed after installation of graphViz via pip?

查看:930
本文介绍了找不到GraphViz的可执行文件-通过pip安装graphViz后为什么没有安装可执行文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在虚拟环境(Windows 8.1)中安装了pydotplus和graphviz. 现在,我想可视化决策树.但是pydotplus无法找到GraphViz的可执行文件.

I installed pydotplus and graphviz in an virtual environment (Windows 8.1). Now I want to visualize a decision tree. However pydotplus is not able to find GraphViz's executables.

from sklearn import tree
from sklearn.datasets import load_iris
import pydotplus
from IPython.display import Image

iris = load_iris()
X,y = iris.data[:,2:], iris.target

clf = tree.DecisionTreeClassifier(max_depth=2)
clf.fit(X,y)
dot_data = tree.export_graphviz(clf,
                     out_file=None,
                     feature_names=iris.feature_names[2:],
                     class_names=iris.target_names,
                     rounded=True,
                     filled=True)


graph = pydotplus.graph_from_dot_data(dot_data)
Image(graph.create_png())

人们通过在GraphViz bin目录中添加其PATH来解决此问题.显然,该目录通常是C:\Program Files (x86)\Graphviz2.34\bin\.但是,这不是我的情况.我怎么找到它?

People solved this problem by adding the GraphViz bin directory their PATH. Apparently this directory usually is C:\Program Files (x86)\Graphviz2.34\bin\. However it is not in my case. How can I find it?

推荐答案

据我的评论,您已经使用pip安装了graphviz.事实是,名为 pip in pip 的软件包只是用于graphviz应用程序的python接口.换句话说,它类似于您尝试使用的pydotplus软件包.

As I understood from comments, you've installed graphviz with pip. Thing is, that package named graphviz in pip is just a python interface for graphviz application. In other words, it's something similar to the pydotplus package that you try to get working.

这些软件包的作用是为您提供一些类和方法供您在Python代码中弄乱,而当需要渲染图形时,它们只需调用graphviz二进制文件并将其发送给生成的点源代码即可.当然,要使它们正常工作,您必须在计算机上安装上述提到的graphviz二进制文件.

What these packages do is give you few classes and methods for you to mess around in your Python code, and when it's time to render graph, they just call the graphviz binary and send it the generated dot source code. Of course, for them to work, you have to have the mentioned graphviz binary installed on your machine.

您需要做的就是下载并运行 graphviz安装程序(链接(适用于Windows),则未以任何方式与python和pip连接.安装后,您将在Program Files中获得Graphviz文件夹,其中包含graphviz可执行文件.

What you need to do is download and run graphviz installer (link for Windows), which is not connected with python and pip in any way. After installing it you will get your Graphviz folder in Program Files, with graphviz executables inside.

在使用pydotplus之前,可能需要将此文件夹添加到PATH中.

Probably you will need to add this folder to your PATH before working with pydotplus.

要检查所有设置是否正确,请运行以下命令:

To check if everything's set up, run this command:

> dot -?

您应该看到dot命令手册页.

You should see the dot command manual page.

这篇关于找不到GraphViz的可执行文件-通过pip安装graphViz后为什么没有安装可执行文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆