Macでpython3の環境構築9---Scipyのインストール---
今回はScipyのインストールをします。
参考書として手元に置いてある『パーフェクトpython』では、gfortranとswig(とそれに必要なPCRE)というものを先にインストールしているようなのですが、ネット上ではswigをインストールしているものはあまり見かけませんでした。
swigとはなにか調べてみると、pythonの中でC/C++を呼び出すためのライブラリのようです。
特にswigは必ずしも必要ではないようでしたので、とりあえず、Scipyだけインストールすることにしました。
gfortranのインストール
ということで、まずはgfortranのインストールをします。
次のように打ちます。
hiroshi-no-MacBook-Air:~ hiroshi$ brew install gfortran #「brew install gfortran」と打ってreturnを押す。
するとこんなメッセージがでました。
GNU Fortran is now provided as part of GCC, and can be installed with:
brew install gcc
gfortranはgccの一部として提供されています。brew install gccとすればインストールできます、と表示されているので素直に指示に従ってみます。
hiroshi-no-MacBook-Air:~ hiroshi$ brew install gcc # 「brew install gcc」と打ってreturnを押す。
そうすると、処理が始まります。
==> Installing dependencies for gcc: gmp, mpfr, libmpc, isl
==> Installing gcc dependency: gmp
==> Downloading https://homebrew.bintray.com/bottles/gmp-6.0.0a.yosemite.bottle.
######################################################################## 100.0%
==> Pouring gmp-6.0.0a.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/gmp/6.0.0a: 15 files, 3.2M
==> Installing gcc dependency: mpfr
==> Downloading https://homebrew.bintray.com/bottles/mpfr-3.1.3.yosemite.bottle.
######################################################################## 100.0%
==> Pouring mpfr-3.1.3.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/mpfr/3.1.3: 24 files, 3.6M
==> Installing gcc dependency: libmpc
==> Downloading https://homebrew.bintray.com/bottles/libmpc-1.0.3.yosemite.bottl
######################################################################## 100.0%
==> Pouring libmpc-1.0.3.yosemite.bottle.tar.gz
🍺 /usr/local/Cellar/libmpc/1.0.3: 10 files, 380K
==> Installing gcc dependency: isl
==> Downloading https://homebrew.bintray.com/bottles/isl-0.14.1.yosemite.bottle.
######################################################################## 100.0%
==> Pouring isl-0.14.1.yosemite.bottle.3.tar.gz
🍺 /usr/local/Cellar/isl/0.14.1: 68 files, 3.2M
==> Installing gcc
==> Downloading https://homebrew.bintray.com/bottles/gcc-5.2.0.yosemite.bottle.1
######################################################################## 100.0%
==> Pouring gcc-5.2.0.yosemite.bottle.1.tar.gz
==> Caveats
GCC has been built with multilib support. Notably, OpenMP may not work:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60670
If you need OpenMP support you may want to
brew reinstall gcc --without-multilib
==> Summary
🍺 /usr/local/Cellar/gcc/5.2.0: 1353 files, 248M
で、確認のためもう一度同じコマンドを打ってみます。
hiroshi-no-MacBook-Air:~ hiroshi$ brew install gcc #「brew install gcc」と打ってreturnを押すと、、、
Warning: gcc-5.2.0 already installed # すでにインストールされてますよ、と出る。
gfortranのインストールはこれで完了。
Scipyのインストール
gfortranのインストールさえしてしまえば、あとはほとんどやることはありません。
「pip3 install scipy」とするだけです。
hiroshi-no-MacBook-Air:~ hiroshi$ pip3 install scipy # 「pip3 install scipy」と打ってreturnを押すと下の行からの処理が始まる。
You are using pip version 7.1.0, however version 7.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Collecting scipy
Downloading scipy-0.16.0-cp34-cp34m-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_x86_64.whl (19.7MB)
100% |████████████████████████████████| 19.7MB 19kB/s
Installing collected packages: scipy
Successfully installed scipy-0.16.0
「Successfully installed scipy-0.16.0」と出ているので無事インストール終了です。
でもさ。少し疑問。
gccってXcodeをインストールしたときに一緒にインストールしなかったっけ?それとは違うのか?。
わかる人いたらご教示ください。