问题复现代码语言:javascript代码运行次数:0
运行 复制import keras from keras.models import Modelfrom keras.layers import Inputfrom keras.layers import Conv2Dfrom keras.layers import GlobalAveragePooling2Dfrom keras.layers import Denseimport numpy as npfrom keras.utils import plot_modelimport osos.environ["PATH"] += os.pathsep + r'E:\Program Files (x86)\Graphviz2.38\bin'A = Input(shape=(16,16,3))x = Conv2D(filters=10, kernel_size=(3,3), padding='same', activation='relu')(A)x = Conv2D(filters=10, kernel_size=(3,3), padding='same', activation='relu')(x)x = GlobalAveragePooling2D()(x)x = Dense(units = 5, activation='softmax')(x)model = Model(A,x)model.summary()test_input = np.random.rand(1,16,16,3)results = model.predict(test_input)plot_model(model)
代码语言:JavaScript代码运行次数:0
运行 复制builtins.OSError: `pydot` failed to call GraphViz.Please install GraphViz (https://www.graphviz.org/) and ensure that its executables are in the $PATH.
问题原因与解决方案:
情况 1
原因:未安装GraphViz。
解决方案:安装相应模块。
代码语言:JavaScript代码运行次数:0
运行 复制pip install pydot-ng pip install graphviz pip install pydot
情况 2
原因:GraphViz程序未加入到系统路径。
解决方案:下载
graphviz-2.38.msi

情况 3
原因:依赖模块已安装、程序已加入系统变量,但仍出现上述提示,因为
pydot
Dot
Dot
解决方案:修改代码。在报错位置找到
pydot
Dot

找到
Dot
代码语言:JavaScript代码运行次数:0
运行 复制class Dot(Graph): """A container for handling a dot language file. This class implements methods to write and process a dot language file. It is a derived class of the base class 'Graph'. """
找到其中的
self.prog = 'dot'
代码语言:JavaScript代码运行次数:0
运行 复制import platformsystem = platform.system() if system == 'Windows': self.prog = 'dot.exe'else: self.prog = 'dot'
保存并再次运行程序。

以上就是解决 Windows OSError - pydot failed to call GraphViz.Please install GraphViz 报错的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号