LoginSignup
3
4

More than 3 years have passed since last update.

長年苦戦していたpython-controlのインストール方法

Posted at

はじめに

今まで何度もpython-controlをインストールしては失敗していた。
今回Readmeにも書いてあるようにDependenciesをしっかり一からダウンロードしていったらできたので、メモ書き程度にここに書き残しておく

なぜpython-control?

制御工学出身の人であれば、matlabのbode関数や,step、根軌跡の描画などにお世話になっていることでしょう。
ただ、pythonに移行してしまった人、もしくはmatlabが高くて買えないひとにとって何かしらの代替案が欲しい。
そこで、同じような関数が揃って、しかも使い勝手もほぼ一緒のpython-controlを使いましょうというお話。

環境

Mac OS Mojave (Sierraとかでも試した)

失敗

まずは何となくGitHugのレポジトリを眺めて、あーpipで入れられるんだと思って以下のコマンドを叩いた。

pip install slycot   # optional; see below
pip install control

そうすると、BLAS/LAPACKがないだの色々怒られる・・・
そこで

brew tap homebrew/science
brew install openblas

などで対処しても失敗する。

インストール方法

ここに書いてあるdependeciesを愚直に1個1個ダウンロードしていく。
python, numpy scikit-buildは入っている前提とする。

  • Python 2.7, 3.5+
  • NumPy
  • scikit-build >=0.8.1
  • cmake
  • C compiler (e.g. gcc, MS Visual C++)
  • FORTRAN compiler (e.g. gfortran, ifort, flang)
  • BLAS/LAPACK (e.g. OpenBLAS, ATLAS, MKL)

c compilerは確認程度

gcc -v
ない場合は、xcodeか何かでインストール

cmakeインストール

brew install cmake

FORTRAN compilerのインストール

ここのサイトの通りインストール

gfortran -v

でインストールできたか確認

BLAS / LAPACKのインストール

[参考](https://pheiter.wordpress.com/2012/09/04/howto-installing-lapack-and-blas-on-mac-os/)

  1. まず、zipファイルをダウンロードしてunpack
  2. BLAS: http://www.netlib.org/blas/
  3. LAPACK: http://www.netlib.org/lapack/

  4. BLASからインストール
    unzipしたら、その場で

make

すると、blas_UNIX.a もしくはblas_LINUX.aファイルができるので、
libblas.aという名称に変更してライブラリフォルダに移動

mv blas_LINUX.a libblas.a
sudo cp libblas.a /usr/local/lib/
  1. LAPACKのインストール LAPACKは色々なmake方法?があるので、gfortranでインストールする。
cp INSTALL/make.inc.gfortran make.inc
make

blasと同様にライブラリフォルダに移動

sudo cp liblapack.a /usr/local/lib/
  1. slycotとpython-controlのインストール
pip install slycot   # optional; see below
pip install control
3
4
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
3
4