Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] mecab-python3 throws error "symbol not found in flat namespace '__ZN5MeCab11createModelEPKc'" #2210

Closed
agilebean opened this issue Dec 13, 2022 · 4 comments
Labels
bug Something isn't working

Comments

@agilebean
Copy link

agilebean commented Dec 13, 2022

Describe the bug

On an Apple Silicon M1 with MacOS Ventura, I could replicate the following for

  • miniforge3
  • mambaforge
    and several models and vocoders.

After the installation process (see To Reproduce section), the following commands work:

tts --list_models
tts --model_info_by_name tts_models/en/ek1/tacotron2
tts --model_info_by_idx tts_models/10

However, the following commands do not work:

tts --text "Text for TTS" --out_path output/speech.wav
tts --text "Text for TTS" --model_name "tts_models/en/ljspeech/glow-tts" --vocoder_name "vocoder_models/en/ljspeech/univnet" --out_path output/speech.wav

They throw the same error from the mecab library:

ImportError: dlopen(/Users/chaehan/mambaforge/envs/tts/lib/python3.10/site-packages/MeCab/_MeCab.cpython-310-darwin.so, 0x000A): symbol not found in flat namespace '__ZN5MeCab11createModelEPKc'

Reinstalling the mecab-python3 library did not make a difference, even when installed from source by:

pip install mecab-python3==1.0.5 --force-reinstall --no-cache-dir --global-option=build_ext

To Reproduce

Installed TTS repo with mamba:

# create mambaforge environment
mamba create -n tts
mamba activate tts

# install arm64 dependency before installing mecab-python3
arch -arm64e /opt/homebrew/bin/brew install mecab

# install dependency python
mamba install python=3.10

# install repo packages
cd tts
pip install -e .[all]

Expected behavior

No response

Logs

Traceback (most recent call last):
  File "/Users/chaehan/mambaforge/envs/tts/bin/tts", line 8, in <module>
    sys.exit(main())
  File "/Users/chaehan/TTS/TTS/bin/synthesize.py", line 316, in main
    synthesizer = Synthesizer(
  File "/Users/chaehan/TTS/TTS/utils/synthesizer.py", line 76, in __init__
    self._load_tts(tts_checkpoint, tts_config_path, use_cuda)
  File "/Users/chaehan/TTS/TTS/utils/synthesizer.py", line 113, in _load_tts
    self.tts_model = setup_tts_model(config=self.tts_config)
  File "/Users/chaehan/TTS/TTS/tts/models/__init__.py", line 12, in setup_model
    MyModel = find_module("TTS.tts.models", config.model.lower())
  File "/Users/chaehan/TTS/TTS/utils/generic_utils.py", line 93, in find_module
    module = importlib.import_module(module_path + "." + module_name)
  File "/Users/chaehan/mambaforge/envs/tts/lib/python3.10/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 883, in exec_module
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "/Users/chaehan/TTS/TTS/tts/models/tacotron2.py", line 13, in <module>
    from TTS.tts.models.base_tacotron import BaseTacotron
  File "/Users/chaehan/TTS/TTS/tts/models/base_tacotron.py", line 14, in <module>
    from TTS.tts.utils.text.tokenizer import TTSTokenizer
  File "/Users/chaehan/TTS/TTS/tts/utils/text/__init__.py", line 1, in <module>
    from TTS.tts.utils.text.tokenizer import TTSTokenizer
  File "/Users/chaehan/TTS/TTS/tts/utils/text/tokenizer.py", line 5, in <module>
    from TTS.tts.utils.text.phonemizers import DEF_LANG_TO_PHONEMIZER, get_phonemizer_by_name
  File "/Users/chaehan/TTS/TTS/tts/utils/text/phonemizers/__init__.py", line 4, in <module>
    from TTS.tts.utils.text.phonemizers.ja_jp_phonemizer import JA_JP_Phonemizer
  File "/Users/chaehan/TTS/TTS/tts/utils/text/phonemizers/ja_jp_phonemizer.py", line 3, in <module>
    from TTS.tts.utils.text.japanese.phonemizer import japanese_text_to_phonemes
  File "/Users/chaehan/TTS/TTS/tts/utils/text/japanese/phonemizer.py", line 7, in <module>
    import MeCab
  File "/Users/chaehan/mambaforge/envs/tts/lib/python3.10/site-packages/MeCab/__init__.py", line 10, in <module>
    from . import _MeCab
ImportError: dlopen(/Users/chaehan/mambaforge/envs/tts/lib/python3.10/site-packages/MeCab/_MeCab.cpython-310-darwin.so, 0x000A): symbol not found in flat namespace '__ZN5MeCab11createModelEPKc'

Environment

- TTS: 0.9.0
- Python: 3.10
- OS: MacOS Ventura
- mecab-python3 1.0.5

Additional context

No response

@agilebean
Copy link
Author

I'm closing this issue as I managed to solve it with the help of polm, the mecab-python3 maintainer.
See here for details.

TL;DR

/opt/homebrew/bin/brew --build-from-source mecab
ARCHFLAGS='-arch arm64' pip install --compile --use-pep517 --no-cache-dir --force -e .

It was not enough to install mecab by homebrew as suggested before, you need to recompile it from source, and make sure that the homebrew for the arm64 is used, hence the path.

Also, you need to compile from source all the libraries, it was not enough to recompile only the mecab-python3 library.

@jrhone
Copy link

jrhone commented May 2, 2023

@agilebean which other libraries are you referring to that need to be recompiled, the dependencies of mecab-python3 or just all libraries in my virtual env?

@colefranks
Copy link

These steps didn't work for me, I still got the symbol not found error. Since I didn't need Japanese I just removed the Japanese phonemizer imports and it worked. i made a fork in case it helps anyone. coqui-without-japanese

@Preston4tw
Copy link

I'm closing this issue as I managed to solve it with the help of polm, the mecab-python3 maintainer. See here for details.

TL;DR

/opt/homebrew/bin/brew --build-from-source mecab
ARCHFLAGS='-arch arm64' pip install --compile --use-pep517 --no-cache-dir --force -e .

It was not enough to install mecab by homebrew as suggested before, you need to recompile it from source, and make sure that the homebrew for the arm64 is used, hence the path.

Also, you need to compile from source all the libraries, it was not enough to recompile only the mecab-python3 library.

This worked, thanks, though I had to tweak these commands slightly. "install" was left off the brew command. I also used a different pip command that includes --no-binary :all: because pip kept wanting to reinstall from a wheel.

brew install --build-from-source mecab
ARCHFLAGS='-arch arm64' pip install --no-binary :all: --compile --use-pep517 --no-cache-dir --force mecab-python3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants