Install GiNZA on macOS (April 2020)

Page content

Install on 3.8.1 - failed

As of April 2020, I tried to install ginza on my macOS laptop in Python 3.8.1 (pyenv-virtualenv).

pip install -U ginza

but it was failed and returned an error like,

...
Collecting ja_ginza_dict<3.2.0,>=3.1.0
  Using cached ja_ginza_dict-3.1.0-1.tar.gz (44.8 MB)
    ERROR: Command errored out with exit status 1:
     command: /Users/atlex/.pyenv/versions/3.8.1/envs/nlp/bin/python3.8 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/hf/kz2h5f215jx73h3vl_d423pr0000gn/T/pip-install-_gi9fc1z/ja-ginza-dict/setup.py'"'"'; __file__='"'"'/private/var/folders/hf/kz2h5f215jx73h3vl_d423pr0000gn/T/pip-install-_gi9fc1z/ja-ginza-dict/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /private/var/folders/hf/kz2h5f215jx73h3vl_d423pr0000gn/T/pip-install-_gi9fc1z/ja-ginza-dict/pip-egg-info
         cwd: /private/var/folders/hf/kz2h5f215jx73h3vl_d423pr0000gn/T/pip-install-_gi9fc1z/ja-ginza-dict/
    Complete output (19 lines):
    Traceback (most recent call last):
      File "/Users/atlex/.pyenv/versions/3.8.1/lib/python3.8/tarfile.py", line 1721, in xzopen
        import lzma
      File "/Users/atlex/.pyenv/versions/3.8.1/lib/python3.8/lzma.py", line 27, in <module>
        from _lzma import *
    ModuleNotFoundError: No module named '_lzma'
    
    During handling of the above exception, another exception occurred:
    
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/private/var/folders/hf/kz2h5f215jx73h3vl_d423pr0000gn/T/pip-install-_gi9fc1z/ja-ginza-dict/setup.py", line 15, in <module>
        with tarfile.open(str(xz_path), 'r:xz') as xz:
      File "/Users/atlex/.pyenv/versions/3.8.1/lib/python3.8/tarfile.py", line 1617, in open
        return func(name, filemode, fileobj, **kwargs)
      File "/Users/atlex/.pyenv/versions/3.8.1/lib/python3.8/tarfile.py", line 1723, in xzopen
        raise CompressionError("lzma module is not available")
    tarfile.CompressionError: lzma module is not available
    extracting /private/var/folders/hf/kz2h5f215jx73h3vl_d423pr0000gn/T/pip-install-_gi9fc1z/ja-ginza-dict/ja_ginza_dict/sudachidict/system.dic.tar.xz
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I wanted to find a solution an here was a clue.

https://github.com/pandas-dev/pandas/issues/27532

And I tried,

brew install xz
pip install -U pylzma
pip install -U backports.lzma

but it still didn’t work.

Solution - Change Python environment to 3.7

I changed my Python environment to 3.7.6, and pip install -U ginza after pip install -U spacy worked fine.

Don’t forget to exec ginza -i once after the install (takes a lot of time).