一、问题描述
我在使用pydot库的时候出现了一个挺常见的问题,那就是我已经安装了pydot库,但是仍然报错。报错的提醒的主要内容是ImportError: Failed to import `pydot`. Please install `pydot`. For example with `pip install pydot。
二、解决方法
查阅资料后,发现单单下载pydot库是无法使用的,这个时候我们需要下载安装pydotplus库和Graphviz。如果我们使用的是anaconda环境的话,直接在anaconda的界面上搜索这两个库就可以了。我们执行以下方法进行下载这三个库。
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pydot
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pydotplus
pip install -i https://pypi.tuna.tsinghua.edu.cn/simple Graphviz
注意:有网友曾遇到安装了这三个库都无法使用的情况,在这种情况下,有种简单的方法,就是把这三个库先卸载掉,然后再按照顺序安装pydot,pydotplus,Graphviz这三个库。