Python3でstatsmodelsをなんとかインストールした
はじめに
今まで統計関連のコードはRで書いてたのですが、最近はこれをPythonに置き換えようと色々なライブラリを試してます。
で、その過程でstatsmodelsをインストールしようとしたらエラーが出たんですが、なんとか解決したので、その方法を忘れないようにメモしておきます。
状況
- Pythonのバージョンは3.4.1
pip3 install statsmodels
でビルドエラー
エラーログは以下のような感じ(一部抜粋)
statsmodels/tsa/kalmanf/kalman_loglike.c:7021:19: error: no member named 'f_tstate' in 'struct _frame' (*frame)->f_tstate = PyThreadState_GET(); ~~~~~~~~ ^ 1 warning and 1 error generated. error: command 'clang' failed with exit status 1
解決法
以下のステップを踏むことで解決しました。
pip3 install cython
で、Cythonをインストールする- Cythonのバージョンが
0.20.1
以上であることを確認する pip3 install git+https://github.com/statsmodels/statsmodels.git
で、GitHubのリポジトリからインストールする
おわりに
これで一日無駄にした