polm / fugashi

A Cython MeCab wrapper for fast, pythonic Japanese tokenization and morphological analysis.
MIT License
389 stars 31 forks source link

Can't install on MacOS Ventura Intel x86 Python 3.11 #81

Closed tak2hu closed 1 year ago

tak2hu commented 1 year ago

I already installed mecab and unidic-lite

Collecting fugashi
  Using cached fugashi-1.2.1.tar.gz (337 kB)
  Preparing metadata (setup.py) ... error
  error: subprocess-exited-with-error

  × python setup.py egg_info did not run successfully.
  │ exit code: 1
  ╰─> [9 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/private/var/folders/zj/qrp2fd392hz9t9f8kpnbkr600000gn/T/pip-install-n9jm53hb/fugashi_08463b6ceb92463991c8021884dcd2d4/setup.py", line 15, in <module>
          output, data_files = check_libmecab()
                               ^^^^^^^^^^^^^^^^
        File "/private/var/folders/zj/qrp2fd392hz9t9f8kpnbkr600000gn/T/pip-install-n9jm53hb/fugashi_08463b6ceb92463991c8021884dcd2d4/fugashi_util.py", line 58, in check_libmecab
          raise RuntimeError("Could not configure working env. Have you installed MeCab?")
      RuntimeError: Could not configure working env. Have you installed MeCab?
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.
polm commented 1 year ago

This can happen if mecab-config is not in your PATH. This doesn't seem to usually be an issue on OSX, but maybe you installed to a different location or something? How did you install MeCab?

tak2hu commented 1 year ago

I installed mecab through pip install mecab-python3 (also unidic_lite too) but there's no mecab-config, there's only mecab-py and mecab-py-info in PATH.

I then tried tried using micromamba (anaconda) with python 3.9 and had no problem because it downloaded .whls instead of building.

polm commented 1 year ago

I installed mecab through pip install mecab-python3 (also unidic_lite too) but there's no mecab-config, there's only mecab-py and mecab-py-info in PATH.

To install MeCab from source, as you were doing here, you need to install the original MeCab C++ program/library, not any Python package. fugashi cannot use the MeCab included in mecab-python3. I believe the usual way to install MeCab from source is via brew, as described here.

It sounds like this is resolved now since you were able to use x86 wheels?

tak2hu commented 1 year ago

I opened this issue because there was no osx x86 py3.11 wheels and I didn’t know how to build this and mecab from source, now I know. Thanks!

polm commented 1 year ago

Got it, thanks for the clarification, and glad you figured it out!