ubuntu1804报错‘Failed to import pydot. You must `pip install pydot` and install graphviz解决

ubuntu1804报错‘Failed to import pydot. You must pip install pydot and install graphviz解决

问题描述:
描绘网络结构图失败

tf.keras.utils.plot_model(model, show_shapes=True, to_file='YOLOV3Net.png')

报错:

Traceback (most recent call last):
  File "yolo_net.py", line 93, in <module>
    plot_model(model, show_shapes=True, to_file='YOLOV3Net.png')
  File "/home/zhao/anaconda3/lib/python3.8/site-packages/tensorflow/python/keras/utils/vis_utils.py", line 324, in plot_model
    dot = model_to_dot(
  File "/home/zhao/anaconda3/lib/python3.8/site-packages/tensorflow/python/keras/utils/vis_utils.py", line 116, in model_to_dot
    raise ImportError(message)
ImportError: ('Failed to import pydot. You must `pip install pydot` and install graphviz (https://graphviz.gitlab.io/download/), ', 'for `pydotprint` to work.')

安装需要的包

pip install pydot#安装1.4.1版本
pip install graphviz#安装0.16版本

此方法失败(原因可能是两个包版本不匹配)

解决方法

sudo apt-get install graphviz

此时很可能会显示依赖包没装

 graphviz : Depends: libann0 but it is not going to be installed
            Depends: libcdt5 but it is not going to be installed
            Depends: libcgraph6 but it is not going to be installed
            Depends: libgts-0.7-5 (>= 0.7.6) but it is not going to be installed
            Depends: libgvc6 but it is not going to be installed
            Depends: libgvpr2 but it is not going to be installed
            Depends: liblab-gamut1 but it is not going to be installed

装上就好了

sudo apt --fix-broken install

Ohhhhhh!!!
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值