What to do when you can't bind CaboCha to Python

environment

Ubuntu 20.04 LTS pyenv 1.2.8 Python 3.7.3 CaboCha 0.60

Error encountered

$ 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'

I have CaboCha installed and can use it from the command line, but I can't use it from Python.

Solutions

If you are using pyenv and execute the following command, the python path is different from the one used, so ModuleNotFoundError occurs.

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

Instead, run the following command.

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

You can now use it.

reference

https://teratail.com/questions/190826

Recommended Posts

What to do when you can't bind CaboCha to Python
What to do when you get "I can't see the site !!!!"
What to do if you can't pipenv shell
What to do if you can't use scikit grid search in Python
What to do if you can't pip install mysqlclient
What to do if you get an error when installing python with pyenv
What to do when Ubuntu crashes
What to do with PYTHON release?
Python | What you can do with Python
[AWS] What to do when you want to pip with Lambda
What to do if you can't sort files with subscripts
What to do when "SSL: CERTIFICATE_VERIFY_FAILED _ssl.c: 1056" appears in Python
What to do if you can't use WiFi on Linux
ImportError: No module What to do when you are told
What to do if you get an error when importing matplotlib in Python (Mac)
How to install and use pyenv, what to do if you can't switch python versions
What to do if you get a minus zero in Python
What to do if Insecure Platform Warning appears when running Python
What to do if you can't build your project with Maven
What to do if you can't use the trash in Lubuntu 18.04.
What to do when ModuleNotFoundError: No module named'XXX' occurs in Python
What to do when the value type is ambiguous in Python?
What to do if you can't find well with grep's -f option
What to do if you can't find PDO in Laravel or CakePHP
What to do if you get an error when trying to load mnist
What to do if you can't install with pip in babun environment
What to do if you get an error when installing Dlib (Ubuntu)
[Python] What I did to do Unit Test
What to do when PermissionError of tempfile.mkstemp occurs
What I did when updating from Python 2.6 to 2.7
What are you using when testing with Python?
What to do if you can't pipenv shell
What to do if you can't pip install mysqlclient
UnicodeDecodeError: What to do when'shift_jis' codec can't decode byte
What you can't do with hstack or vstack with dstack
What to do when you can't bind CaboCha to Python
What to do if you get a "Wrong Python Platform" warning when using Python with the NetBeans IDE
[Python] What to do if you get a ModuleNotFoundError when importing pandas using Jupyter Notebook in Anaconda
[python] What to do when an error occurs in send_keys of headless chrome
What to do when a warning appears around Python integration in Neovim's CheckHealth
When you can't uninstall the python library. Can't uninstall'hogehoge'. No files were found to uninstall.
What to do when [Errno 2] No such file or directory appears in Python
What to do when you want to receive files from a Windows client remotely
What I do when imitating embedded go in python
[Go 1.13] What to do when unexpected directory layout: appears
[openpyxl] What to do when IllegalCharacterError appears in pandas.DataFrame.to_excel
UnicodeDecodeError: What to do when'shift_jis' codec can't decode byte
No module named What to do if you get'libs.resources'
What to do when raise ValueError, "unsupported hash type"
Links to do what you want with Sublime Text
What you can't do with hstack or vstack with dstack
Things to do when you start developing with Django
What I was addicted to when using Python tornado
I want to do something in Python when I finish
[Python] Type Error:'WebElement' object is not iterable What to do when an error occurs
What to do if "export" keeps appearing on terminal when trying to put Python on macOS
What to do when python3 type venv does not work well on Raspberry Pi
What to do if you get `No kernel for language python found` in Hydrogen
What to do if you get a memory error when converting from PySparkDataFrame to PandasDataFrame
[Python] What to do when No module named'pyproj.datadir' appears when Exe is done with PyInstaller
What to do when Python starts up in Anaconda does not come out unexpectedly
What to do if you get an Import Error when importing matplotlib with Jupyter
What to do if you don't want to use Japanese column names when using ortoolpy.logistics_network
What to do if you get the error ʻERR_FEATURE_UNAVAILABLE_ON_PLATFORM` when using ts-node-dev on Linux
What to do if you run python in IntelliJ and end with an error