0
0

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.

CaboChaをPythonにバインディングできない際にすること

Posted at

環境

Ubuntu 20.04 LTS
pyenv 1.2.8
Python 3.7.3
CaboCha 0.60
※コマンドラインから直接CaboChaを動かすことができるが,pythonへのバインディングだけがうまくいかない人向けです.

遭遇したエラー

$ python
Python 3.7.3 (default, Mar 27 2019, 22:11:17) 
[GCC 7.3.0] :: Anaconda custom (64-bit) on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import CaboCha
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/Jittsu/cabocha-0.60/python/CaboCha.py", line 15, in <module>
    import _CaboCha
ModuleNotFoundError: No module named '_CaboCha'

CaboChaのインストールはできており,コマンドラインからの使用はできるが,Pythonから使うことができない状態が起きました.

解決方法

pyenvを使用している方が以下のコマンドを実行すると,pythonのパスが使用しているものと異なるため,
ModuleNotFoundErrorが発生する.

$ sudo python3 setup.py build_ext
$ sudo python3 setup.py install
$ sudo /sbin/ldconfig

代わりに以下のコマンドを実行する.

$ sudo $(which python) setup.py build_ext
$ sudo $(which python) setup.py install
$ sudo /sbin/ldconfig
$ python
Python 3.7.3 (default, Mar 27 2019, 22:11:17) 
[GCC 7.3.0] :: Anaconda custom (64-bit) on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import CaboCha
>>>

使えるようになりました.

参考

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?