1
1

More than 1 year has passed since last update.

はじめての記事投稿

KH CoderをMacへインストールする最短手順

Posted at

2023年6月段階の最短手順を書き残しておく。無駄な手順がもしかしてあるかもしれないが、おそらくこれが最短。
ほぼ備忘録なのでミスってる手順もあるかもなので、あればこっそり教えてください。

KH Coderとは?

先輩方がたくさん記事を書いてくれているので、そちらを参考にしてみてください。今回はインストール手順のみなので、割愛します。


下準備

まずは、Terminalを開きます。

Xcodeをインストールする

xcode-select --install
# 多少時間かかります

Homebrewをインストールする

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

インストール後、確認

brew doctor
brew --version
# Versionが表示されたらOK

Gitをインストール

brew install git

具体手順

ものによってはインストール済みかもしれませんが、適宜端折ってください。

XQuartsをインストール

Windows用アプリケーションをMacで起動するためのツールです。

https://www.xquartz.org/index.html からdmgをダウンロードして、インストールします。

openjdkのインストール

オープンソース版のJavaです

brew install openjdk

mecabのインストール

日本語形態素解析システムです。

brew install mecab
brew install mecab-ipadic

mysqlのインストール

オープンソースのSQLデータベースです。

brew install mysql

インストール後、起動して

brew services start mysql
==> Successfully started `mysql` (label: homebrew.mxcl.mysql) #成功したらこれが出る

データベースの初期設定を行います。

mysql_secure_installation 
# DBの初期化

> Securing the MySQL server deployment.

> Enter password for user root:  
# PCのパスワードを入力

> ~~~
> Change the password for root ? ((Press y|Y for Yes, any other key for No) :
# Y or Nで進める

> ~~~
> Remove anonymous users? (Press y|Y for Yes, any other key for No) : 
# Yでanonymous usersは削除する

> ~~~
> Disallow root login remotely? (Press y|Y for Yes, any other key for No) :
# Y で進める

> ~~~
> Remove test database and access to it? (Press y|Y for Yes, any other key for No) :
# Y で進める

> ~~~
> Reload privilege tables now? (Press y|Y for Yes, any other key for No) :
# Y で進める

> Success.
> All done!
# これで完了

mysqlの起動

mysql -u root -p

# パスワードを求められるので、PCのパスワードを入力

mysql>
# これが表示されたら起動完了

Rのインストール

統計解析用の開発環境です

brew install --cask R

Rを起動して、インストール確認を行います。

R

> R version 4.3.0 (2023-04-21) -- "Already Tomorrow"
> Copyright (C) 2023 The R Foundation for Statistical Computing
> Platform: aarch64-apple-darwin20 (64-bit)

起動している状態で、以下を入力

options(repos="https://ftp.yz.yamagata-u.ac.jp/pub/cran/")

必要なパッケージをインストール

install.packages(c("ade4", "amap", "Cairo", "cluster", "codetools", "dichromat", "foreign", "ggdendro", "ggplot", "ggnetwork", "ggsci", "gtable", "igraph", "KernSmooth", "lattice", "maptools", "MASS", "Matrix", "mgcv", "munsell", "nlme", "nnet", "permute", "pheatmap", "plyr", "proto", "RcolorBrewer", "Rcpp", "reshape2", "rgl", "rpart", "scales", "scatterplot3d", "slam", "som", "sp", "spatial", "stringr", "survival", "vegan", "wordcloud"), dependencies=TRUE)
#時間かかりますが、ほっておけば終了します

終わったら、Rを終了します。

Rを終了するためには、quit()またはq()と入力します。


perlのパッケージインストール

まず、rootへ

sudo su
#パスワードを求められるので、入力してEnter。

Perlを起動する

perl -MCPAN -e shell

以下のパッケージをインストール

install Jcode
install Tk
install DBD::CSV
install Net::Telnet
install YAML
install Spreadsheet::ParseExcel
install Spreadsheet::ParseXLSX
install Clipboard
install Statistics::Lite
install Algorithm::NaiveBayes
install Text::Iconv
install File::Copy::Recursive

終わったら、perlを終了します。

perlを終了するためには、exitと入力します。

KH Coderのダウンロード

Githubからダウンロードします。

ダウンロードしたら、適切な場所へ移動します。今回は便宜上Desktopに置いておきます。

移動後、解凍してください。

(以下手順は、Desktopへ移動させた想定で進めます。)

cd ~/Desktop/khcoder

初期設定を行う

nano config/coder.ini

開いたら、以下の箇所を変更する

sql_username    root
sql_password    mysql設定時にセットしたパスワード

nanoエディタで保存する際は、Control + Xを押して、Yと入力して、Enterします。

上記が完了すると、KH Coderが起動できます

perl kh_coder.pl

具体的なKH Coderの使い方は、冒頭の通り先輩方の記事を参考にしてみてください〜

1
1
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
1
1