mac mecab dlopen: symbol not found in flat namespace error

319 Views Asked by At

enter image description here

I want to import MeCab and use it, but that error comes out repeatedly. MeCab-python is well installed. I've tried Brew install and so on, and it's still the same. I'd appreciate it if you could help me if you knew the solution.

1

There are 1 best solutions below

0
Ahmed Fasih On

Hmm. On a fresh macOS 13.1 Ventura, I just did this:

  1. Installed miniconda https://docs.conda.io/en/latest/miniconda.html#latest-miniconda-installer-links
  2. conda create -n mecab-tutorial and answering questions
  3. conda activate mecab-tutorial
  4. conda install python ipython and saying 'yes'
  5. python -m pip install mecab-python3 unidic-lite

Then I was able to run this script:

import MeCab
wakati = MeCab.Tagger("-Owakati")
wakati.parse("pythonが大好きです").split()
# ['python', 'が', '大好き', 'です']

Looking at the path in the error in the screenshot, it looks like you installed a global Python in /Library which I don't want to try because I very much prefer to keep my Python environments local, hence using Conda above to create a custom environment to install MeCab packages in to ensure no cross-contamination later.

There's no guarantee that this will work if you try it since the error you're seeing seems to be a compiler issue (Python is finding MeCab, just having trouble calling a C++ function inside the binary), but if possible, can you try the Conda approach above?