Closed polm closed 1 year ago
Leaving this incase anyone else can benefit:
I was able to compile it myself using the following on an M1 Mac:
pip3 download mecab-python3
tar xfv mecab-python3-1.0.5.tar.gz
cd mecab-python3-1.0.5
brew install mecab
python3 setup.py build
python3 setup.py install
pip3 list
For me this was the missing part:
brew install mecab
I'm not familiar with the brew
distribution of MeCab, but that is one way to install it instead of building directly from source. If you use their version you should check if they've patched it in any way.
I'm not familiar with the
brew
distribution of MeCab, but that is one way to install it instead of building directly from source. If you use their version you should check if they've patched it in any way.
I can confirm that building by source does not work, but the above answers to build mecab with brew do work successfully on an M1 CPU
When you say building from source does not work, what do you mean? What error do you get?
Note that installing MeCab from source is a separate step before building mecab-python3 from source.
When you say building from source does not work, what do you mean? What error do you get?
Note that installing MeCab from source is a separate step before building mecab-python3 from source.
@polm
Following the solution by @gokalper with pip3 download mecab-python3
, the current version downloaded throws a compatibility issue:
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
tts 0.9.0 requires mecab-python3==1.0.5, but you have mecab-python3 1.0.6 which is incompatible.
So you need to know before to install by:
pip install mecab-python3==1.0.5
Adding to homebrew solution suggested, it is essential that
/opt/homebrew/bin/brew
The last point is essential if you use another homebrew installation for the intel architecture.
What is the actual error you get if you build MeCab from source first? Using brew is also fine, but it still isn't clear to me what went wrong just building from source.
The "compatibility issue" you mention seems to be a conflict with the requirements of tts, a text to speech package, that has pinned a specific older version of this library. That is not a bug, and it only affects users of tts
. Also note it's a warning - the code should work anyway, since the only change in 1.0.6 was adding 3.11 wheels.
It makes sense that you would use the M1 version of brew if you want an M1 build.
What is the actual error you get if you build MeCab from source first? Using brew is also fine, but it still isn't clear to me what went wrong just building from source.
The "compatibility issue" you mention seems to be a conflict with the requirements of tts, a text to speech package, that has pinned a specific older version of this library. That is not a bug, and it only affects users of
tts
.
Yes you're right. I realized that after posting this.
Also note it's a warning - the code should work anyway, since the only change in 1.0.6 was adding 3.11 wheels.
Good to know.
It makes sense that you would use the M1 version of brew if you want an M1 build.
So I think you can close this issue then
OK, thanks for clarifying. This issue is not just about using the package on M1 machines, it's about my ability to provide wheels. If you want to stay updated on progress you can subscribe to it, and when Github Actions or some other method becomes available I'll update this.
For now I'll hide all these comments, since they're off topic.
Looking over this again, it just occurred to me that I should clearly state I expect this should work:
brew install mecab
pip install mecab-python3
I don't have a Mac to check this, but you shouldn't have to do the pip download
and other steps - pip will install from source by default if it can't find a wheel. (I guess this is what @amitkot was saying upthread.)
@polm Yes you're right. However, on Apple Silicon, you need to force both commands to compile from source, as mentioned here
/opt/homebrew/bin/brew install mecab --build-from-source
ARCHFLAGS='-arch arm64' pip install --compile --use-pep517 --no-cache-dir --force" mecab-python3==1.0.5
@agilebean just a small correction, there is a misplaced double quote in your command; I think it should be
/opt/homebrew/bin/brew install mecab --build-from-source
pip install unidic-lite # in case someone missed it from the README
ARCHFLAGS='-arch arm64' pip install --compile --use-pep517 --no-cache-dir --force mecab-python3==1.0.5
@BenQuigley this will run me into an error:
ARCHFLAGS='-arch arm64' pip install --compile --use-pep517 --no-cache-dir --force mecab-python3==1.0.5
Collecting mecab-python3==1.0.5
Downloading mecab-python3-1.0.5.tar.gz (77 kB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 77.6/77.6 kB 884.4 kB/s eta 0:00:00
Installing build dependencies ... error
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> [6 lines of output]
Collecting setuptools>=40.8.0
Using cached setuptools-67.8.0-py3-none-any.whl (1.1 MB)
Collecting wheel
Using cached wheel-0.40.0-py3-none-any.whl (64 kB)
Installing collected packages: wheel, setuptools
ERROR: Cannot set --home and --prefix together
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
error: subprocess-exited-with-error
× pip subprocess to install build dependencies did not run successfully.
│ exit code: 1
╰─> See above for output.
tar xfv mecab-python3-1.0.5.tar.gz
Worked for my M1!
yes, I needed to install and not build from scratch, then it worked for me too :-)
This should be resolved in fugashi thanks to https://github.com/polm/fugashi/pull/80. I have just made a release there, and if that goes smoothly I will port the M1 build over here eventually.
I have made an alpha release that includes what I think are working M1 wheels. You can install it like so:
pip install mecab-python3==1.0.8a1
If I can get some confirmation that this works I will make a release.
@polm Just tried installing on M2 using Python 3.11 and it works great!
Thank you for the confirmation, I have made a 1.0.8 release with the wheels, which should be available shortly.
This has been released. Thanks to everyone who provided advice to users inconvenienced by this issue.
There are no wheels for the OSX M1 / arm64 architecture. They are not available because I do not have a way to automate builds.
Please see https://github.com/polm/fugashi/issues/55#issuecomment-1158463940 for more details and progress updates.
Note that in the meantime you have two options:
brew install mecab
first.)