背景
テキストマイニングのためのフリーソフトウェアとして有名なKH Coderをインストールしたときのメモです。
デファクトスタンダードは、Windowsにインストールするのですが、perlとRとTKで動いているためクロスプラットフォームで動きます。自分はMacしか持っていなかったため、Macにインストールしました。
環境
OS: 10.12.3(Sierra)
shell: bash
インストール
KH CoderをMacにインストール
=> perl以外はこっちがオススメ
Mac】KH Coder導入手順
=> perlのインストールは、cpanmを使ったこっちがオススメ
brew
で失敗することはなく、perlのモジュールをインストールしたときに失敗しました。
perl -MCPAN -e shell
ではTK, Clipboardが失敗したため、cpanm
でインストールしたらうまくインストール出来た記憶があり
ます。make
とかはしなくても動きました。
また、一度失敗しても、cpanm Clipboard --force
などと--force
をつけると動く場合があります。
どうしてもインストールできない場合は、公式に有償サポートがありますので、こちらを使うと早いと思います。
=> Macで手軽にKH Coderを[有償サポート]
※ インストール時は言語環境がUTF8でも問題ないです。
X Winodow Systemについて
kh_coderの起動にはX Winodow Systemが必要です。Macでは、xquartzというアプリケーションでX Window Systemが使えます。ここからdmgファイルをダウンロードしインストールします。
インストールするとターミナルの中でstartx
コマンドが使えるようになります。
kh_coderを起動する
kh_coderはターミナルから起動します。ターミナルのデフォルト言語環境はUTF8です。kh_coderはSJISの環境で起動する必要があるため、ターミナルの言語環境をSJIS
に変更してから起動してください。
X Window Systemを起動する
kh_coderを起動するには、xwindowを事前に起動する必要があるためstartx
コマンドを実行します。
startx
出力結果
正常時
This is KH Coder 2.00f on darwin.
CWD: /Applications/kh_coder
R Version: 3.3, x86_64
Using un-threaded functions...
文字コードは間違っていると、起動はしますが、下記のエラーが出ます。
font_cache: Scanning user font directories to generate X11 font caches
font_cache: Updating FC cache
font_cache: Done
expr: syntax error
expr: syntax error
expr: syntax error
xauth: file /Users/xxxxx/.serverauth.94212 does not exist
xauth: (argv):1: bad display name "xxxxxx.local:0" in "list" command
xauth: (stdin):1: bad display name "xxxxxx.local:0" in "add" command
/opt/X11/bin/xinit: XFree86_VT property unexpectedly has 0 items instead of 1
※: xxxxxx
は、自分のフォルダー名/PC名なのでマスクした
kh_coderを起動する
perl kh_coder.pl
kh_coderが起動しない場合
X Window Systemが起動していないとperk kh_coder.pl
を実行したときに下記のエラーが出力されます。
ターミナルの言語環境はSJISに設定しstartx
コマンドを実行しましょう。
This is KH Coder 2.00f on darwin.
CWD: /Applications/kh_coder
sh: line 1: 94387 Killed: 9 /usr/local/bin/R --slave --vanilla < start.r > output.log
R Version: 3.3, x86_64
Using un-threaded functions...
couldn't connect to display ":0" at /Library/Perl/5.18/darwin-thread-multi-2level/Tk/MainWindow.pm line 53.
MainWindow->new() at /Applications/kh_coder/kh_lib/gui_window.pm line 117.
Warning message:
In Sys.setlocale(category = "LC_ALL", locale = "ja_JP.EUC-JP") :
OS reports request to set locale to "ja_JP.EUC-JP" cannot be honored