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!!!