Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
1
Help us understand the problem. What is going on with this article?
@omuram

libiconv.2.dylibのversionが古いというエラー解決法

More than 1 year has passed since last update.

エラー

Pythonでcabochaを使いたかったため、importしてみた
ipythonにて

In [1]: import CaboCha
ImportError: dlopen(/anaconda/lib/python3.6/site-packages/_CaboCha.cpython-36m-darwin.so, 2): Library not loaded: @rpath/libiconv.2.dylib
  Referenced from: /anaconda/lib/python3.6/site-packages/_CaboCha.cpython-36m-darwin.so
  Reason: Incompatible library version: _CaboCha.cpython-36m-darwin.so requires version 8.0.0 or later, but libiconv.2.dylib provides version 7.0.0

共有ライブラリらへんでエラーがでているっぽい
ググってみたが
https://qiita.com/lapun/items/65039e59ac483c8dfd80

$ brew update
$ brew install libiconv

上のサイトのように試してみても変化なし
他にもportでupdateしようとしたが変化なし

libiconv.2.dylibのversionの確認

$ otool -L /anaconda/lib/python3.6/site-packages/_CaboCha.cpython-36m-darwin.so
/anaconda/lib/python3.6/site-packages/_CaboCha.cpython-36m-darwin.so:
    /usr/local/lib/libcabocha.5.dylib (compatibility version 6.0.0, current version 6.0.0)
    /usr/local/lib/libcrfpp.0.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/local/lib/libmecab.2.dylib (compatibility version 3.0.0, current version 3.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
    @rpath/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

libiconv.2.dylibのversionはcurrent version 8.1.0なのでいいはず、、、
libiconv.2.dylibは/usr/lib/libiconv.2.dylib/opt/local/lib/libiconv.2.dylibがあるらしい
今は@rpath/usr/lib/が入っており/usr/lib/libiconv.2.dylibが使われているよう

それぞれのversion確認

$ otool -L /usr/lib/libiconv.2.dylib
/usr/lib/libiconv.2.dylib:
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)
$ otool -L /opt/local/lib/libiconv.2.dylib
/opt/local/lib/libiconv.2.dylib:
    /opt/local/lib/libiconv.2.dylib (compatibility version 9.0.0, current version 9.0.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

見てみると/opt/local/lib/libiconv.2.dylibを使えば良さそう

libiconv.2.dylibを置き換える

$ sudo install_name_tool -change "@rpath/libiconv.2.dylib"  "/opt/local/lib/libiconv.2.dylib" /anaconda/lib/python3.6/site-packages/_CaboCha.cpython-36m-darwin.so

参考:https://qiita.com/itoru257/items/d36b4e3908a39bfbbb18

すると

$ otool -L /anaconda/lib/python3.6/site-packages/_CaboCha.cpython-36m-darwin.so
/anaconda/lib/python3.6/site-packages/_CaboCha.cpython-36m-darwin.so:
    /usr/local/lib/libcabocha.5.dylib (compatibility version 6.0.0, current version 6.0.0)
    /usr/local/lib/libcrfpp.0.dylib (compatibility version 1.0.0, current version 1.0.0)
    /usr/local/lib/libmecab.2.dylib (compatibility version 3.0.0, current version 3.0.0)
    /usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 104.1.0)
    /opt/local/lib/libiconv.2.dylib (compatibility version 8.0.0, current version 8.1.0)
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.0.0)

pathが置き換わっている(current versionは変わってない、、)のでimportしてみる

In [1]: import CaboCha

In [2]:

importできた!

(/opt/local/lib/libiconv はmacportsでupgradeできるっぽいのだが、/usr/lib/libiconv.2.dylib のupgradeの方法がわからなかったので、前者に置き換えた感じ)

1
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
omuram
東大情報理工M1

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
1
Help us understand the problem. What is going on with this article?