0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

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

Last updated at Posted at 2018-02-01

##エラー
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の方法がわからなかったので、前者に置き換えた感じ)

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?