LoginSignup
2
3

More than 5 years have passed since last update.

Macのanaconda3にpolyglotをインストールする

Last updated at Posted at 2018-11-16

前提

Macにpolyglotをインストールしようとしたのですが、icuがうまくインストールできませんでした。
Homebrewでicu4cをインストールしたつもりになっても、その後のpyicuのインストールでコケます。エラーメッセージは以下。
FileNotFoundError: [Errno 2] No such file or directory: 'icu-config': 'icu-config'
なので、anaconda3を用いればいいかもしれないと思い、普通にanaconda3で新規環境を用意してpipで各種ライブラリをインストールしようとすると、今度はCompileError: command 'gcc' failed with exit status 1といってgccの異常でコケます。
何これ、訳ワカンねぇよ!
とは思いましたが、何とか素直な感じにpolyglotをanaconda環境にインストールできたので、残しておきます。

やり方

# Anacondaでpython3.6を指定してpolyglotと言う名前の仮想環境を作る
$conda create -n polyglot python=3.6 --no-deps -y
# 先ほど作った環境に移動
$source activate polyglot
# numpyは普通にインストール
$conda install numpy
# icuとpyicuをインストールするときにconda-forgeを指定する
$conda install -c conda-forge icu
$conda install -c conda-forge pyicu
# 残りの関連ライブラリをインストール
$pip install morfessor
$pip install pycld2
# ここまで来てようやくpolyglotをインストールします
$pip install polyglot

ちなみに、この方法を見つけるのには下記のコメントが役に立ちました。
https://github.com/aboSamoor/polyglot/issues/80#issuecomment-266301717
このコメントではicuは54.1を使えとありましたが、むしろそれだと上手くいかなかった(理由は忘れました、すみません…)ので、Anaconda Cloud ( https://anaconda.org/ ) から良さげなパッケージを検索して、conda-forgeのicuとpyicuを入れることにしました。
これで上手く行ってくれたのは本当に幸いでした。

余談

辞書等のダウンロード場所をセッティングするには、
export POLYGLOT_DATA_PATH=/directry/you/choiced
という環境変数を設定してあげてください。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3