目录
一.pydot库安装
pydot的安装可直接在编译器安装相关包,以PyCharm举例:

如果搜索可用软件包显示为空,记得在此处把使用Conda软件包管理器"点亮

二.graphviz库安装
点击链接下载安装包graphviz-2.38.msi ,开始安装:
记住安装的路径,后续需要配置环境
完成安装后配置环境变量
计算机→属性→高级系统设置→高级→环境变量→系统变量/用户变量→path,在path中加入你刚安装设置的路径:C:\Program Files (x86)\Graphviz2.38\bin
在什么变量中添加路径取决你跑代码的环境,如果在base环境下跑代码,则在系统变量中添加graphviz路径,如果在自己配置的环境下跑代码,则在用户变量中添加 graphviz路径。
在环境变量/系统变量处选中路径Path点击编辑,然后新建环境变量,路径为刚刚安装时设置的路径:


环境变量添加成功
在cmd中输入dot -version检测是否安装成功
显示下述内容则安装成功:

在Python中使用需要在相应环境内再安装一次graphviz库
pip install graphviz

在Pycharm中检测是否能够使用graphviz库
输入以下代码,若环境安装成功,可以成功输出VGG16的结构图
keras的安装可以参考博主写的教程:
python
from keras.applications import VGG16
from keras.utils import plot_model
from IPython.display import Image
conv_base=VGG16(weights='imagenet',
include_top=True)
# conv_base.summary()
plot_model(conv_base,show_shapes=True,to_file='VGG16.png')
Image(filename='VGG16.png')

