【问题标题】:`pydot` failed to call GraphViz.Please install GraphViz and ensure that its executables are in the $PATH`pydot` 调用 GraphViz 失败。请安装 GraphViz 并确保其可执行文件在 $PATH 中
【发布时间】:2020-05-25 20:43:29
【问题描述】:

My jupyter server is running in a gcp deep learning vm.

我正在尝试在 Jupyter 笔记本单元格中打印模型。

import os, sys
from utils.models.alexnet import alexnet
from keras.utils.vis_utils import plot_model
from keras.optimizers import SGD

model = alexnet(len(class_names))
model.summary()
plot_model(model, to_file="alexnet_model.png", show_shapes=True)

我收到此错误

`pydot` failed to call GraphViz.Please install GraphViz ([https://www.graphviz.org/](https://www.graphviz.org/)) and ensure that its executables are in the $PATH.

我已经在我的机器上正确安装了 Graphviz

apt-get install graphviz

stat /usr/bin/dot
  File: /usr/bin/dot
  Size: 10568       Blocks: 24         IO Block: 4096   regular file
Device: 801h/2049d  Inode: 142872      Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2020-02-10 11:48:19.416617639 +0000
Modify: 2017-02-19 10:32:17.000000000 +0000
Change: 2019-12-13 01:47:41.084977709 +0000

还安装了python包pydot、pydot-ng、pydotplus。

这是我的路径变量

echo $PATH
/usr/local/cuda/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

/user/bin 包含在此处。

编辑

在 jupyter notebook shell 中执行时。

print(os.environ["PATH"])

/usr/local/cuda/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games

另一个奇怪的事情

我有一个简单的图像数据集,其中包含 3 个类和大约 2000 张图像。在我的 jupyter notebook 中,我首先处理图像并将其加载到内存中。接下来是创建模型并打印它。使用简单的数据集,它可以正常工作。当我使用大型数据集时会发生这种情况。

【问题讨论】:

  • 你在本地安装了dot工具,但这不应该在云服务器上吗?是否 100% 确定 jupyter 中使用的路径在其路径中包含 /usr/bin(检查您要使用它的位置)?
  • os.path.exists('/usr/bin/dot') 在 Jupyter Notebook 中执行时会发出什么?
  • @CharlesDuffy 它返回 True
  • 谢谢 - 这表明dot 已安装在您的 GCP 节点上,而不仅仅是您的本地客户端。

标签: python keras jupyter graphviz pydot


【解决方案1】:

我也得到了同样的东西,所以我安装了 conda install python-graphviz 在 conda 安装 pydot 之后

【讨论】:

    【解决方案2】:

    我也有同样的问题,按照Prerna Verma的回答解决了。顺便说一下,在 Linux Env​​s 中使用 graphviz 有三个步骤:

    1. sudo apt-get install graphvizdownload and install graphviz,如果您是 Windows 用户)

    2. conda install pydot

    3. conda install python-graphviz

    那么,你可以使用它了!

    【讨论】:

    • 使用$ dot -V检查graphviz是否安装成功
    【解决方案3】:

    conda 仅安装 graphviz 的二进制文件,但您还需要安装 Python 依赖项。所以安装它们:

    conda install graphviz    
    
    conda install python-graphviz
    

    【讨论】:

      【解决方案4】:

      这为我解决了这个问题:

      sudo apt install python-pydot python-pydot-ng graphviz
      

      参考问题:https://github.com/WillKoehrsen/Data-Analysis/issues/36

      【讨论】:

        猜你喜欢
        • 2016-08-21
        • 2015-09-25
        • 2016-05-05
        • 1970-01-01
        • 2021-04-23
        • 2015-02-13
        • 2017-07-03
        • 2019-10-04
        • 2018-06-20
        相关资源
        最近更新 更多