Couldn’t import dot_parser(エラー?)の解決方法

caffe2をソースからビルドしてチュートリアルを実践したら、以下のようなエラーにも似た文言が吐き出された。エラーでもウォーニングでもないから別に気にする必要もないんだろうけど、気になったので調べてみた。

スポンサーリンク

Couldn’t import dot_parserの解決法

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from matplotlib import pyplot as plt
import numpy as np
import os
import lmdb
import shutil
from imageio import imread
import caffe2.python.predictor.predictor_exporter as pe
from caffe2.proto import caffe2_pb2
from caffe2.python.predictor import mobile_exporter
from caffe2.python import (
    brew,
    core,
    model_helper,
    net_drawer,
    optimizer,
    visualize,
    workspace,
)
# If you would like to see some really detailed initializations,
# you can change --caffe2_log_level=0 to --caffe2_log_level=-1
core.GlobalInit(['caffe2', '--caffe2_log_level=0'])
print("Necessities imported!")
%matplotlib inline
Couldn't import dot_parser, loading of dot files will not be possible.
Necessities imported!

先ずはpydotとpyparsingのバージョンをチェックする。

!pip3 freeze | egrep 'pydot|pyparsing'
pydot==1.2.4
pydot2==1.0.33
pydotplus==2.0.2
pyparsing==2.2.0

とりあえずgraphvizをアンインストールして再インストールし直す。

!apt remove -y graphviz 
!apt install -y graphviz 

上記の方法では駄目だったので次にpython-pydotをインストールしてみた。

!apt-get install -y python-pydot
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following additional packages will be installed:
  python-pyparsing
The following NEW packages will be installed:
  python-pydot python-pyparsing
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.
Need to get 56.6 kB of archives.
After this operation, 278 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu xenial-updates/main amd64 python-pyparsing all 2.0.3+dfsg1-1ubuntu0.1 [35.4 kB]
Get:2 http://archive.ubuntu.com/ubuntu xenial/universe amd64 python-pydot all 1.0.28-2 [21.1 kB]
Fetched 56.6 kB in 1s (47.6 kB/s)      
Selecting previously unselected package python-pyparsing.
(Reading database ... 119234 files and directories currently installed.)
Preparing to unpack .../python-pyparsing_2.0.3+dfsg1-1ubuntu0.1_all.deb ...
Unpacking python-pyparsing (2.0.3+dfsg1-1ubuntu0.1) ...
Selecting previously unselected package python-pydot.
Preparing to unpack .../python-pydot_1.0.28-2_all.deb ...
Unpacking python-pydot (1.0.28-2) ...
Setting up python-pyparsing (2.0.3+dfsg1-1ubuntu0.1) ...
Setting up python-pydot (1.0.28-2) ...

これもだめだったので、今度はpydotとpyparsingの再インストールを行った。

!pip uninstall pydot -y
Uninstalling pydot-1.2.4:
  Successfully uninstalled pydot-1.2.4
!pip uninstall pyparsing -y
Uninstalling pyparsing-2.2.0:
  Successfully uninstalled pyparsing-2.2.0
!pip install pyparsing
Collecting pyparsing
  Using cached https://files.pythonhosted.org/packages/6a/8a/718fd7d3458f9fab8e67186b00abdd345b639976bc7fb3ae722e1b026a50/pyparsing-2.2.0-py2.py3-none-any.whl
Installing collected packages: pyparsing
Successfully installed pyparsing-2.2.0
!pip install pydot
Collecting pydot
Requirement already satisfied: pyparsing>=2.1.4 in /root/.pyenv/versions/3.6.5/envs/py365/lib/python3.6/site-packages (from pydot) (2.2.0)
Installing collected packages: pydot
Successfully installed pydot-1.2.4
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
from __future__ import unicode_literals
from matplotlib import pyplot as plt
import numpy as np
import os
import lmdb
import shutil
from imageio import imread
import caffe2.python.predictor.predictor_exporter as pe
from caffe2.proto import caffe2_pb2
from caffe2.python.predictor import mobile_exporter
from caffe2.python import (
    brew,
    core,
    model_helper,
    net_drawer,
    optimizer,
    visualize,
    workspace,
)
# If you would like to see some really detailed initializations,
# you can change --caffe2_log_level=0 to --caffe2_log_level=-1
core.GlobalInit(['caffe2', '--caffe2_log_level=0'])
print("Necessities imported!")
%matplotlib inline
Necessities imported!

結論としては、pydotとpyparsingの再インストールが解決方法のようだ。

参考サイトhttps://github.com/

参考サイトhttps://stackoverflow.com/