2015年10月5日 星期一

在mac下安裝函式庫SciPy和scikit-learn於python3.4 (2.7)

更新:http://ntudavid.blogspot.com/2015/10/python35-numpy-matplotlib-scipy.html

之前成功安裝了numpy和matplotlib兩個讓Python媲美matlab的兩大函式庫。
這次為了學習machine learning,我們來安裝scikit-learning函式庫。
為了安裝scikit-learn函式庫,我們要先配備函式庫NumPy和SciPy。
http://scikit-learn.org/dev/install.html
好家在的是,我們可以用一個指令輕鬆完成安裝這兩個函式庫。
在Terminal中:
pip install -U scipy scikit-learn      (for Python 2.X)
pip3 install -U scipy scikit-learn     (for Python 3.X)
By the way, 如果還沒有安裝NumPy的朋友,要再多打 numpy喔。
pip install -U numpy scipy scikit-learn      (for Python 2.X)
pip3 install -U numpy scipy scikit-learn     (for Python 3.X)

不過,如果事情有那麼容易的話,就不是人生了。
為了安裝scipy函式庫,會需要有fortran的compilier。
不然會有安裝的錯誤訊息:
error: library dfftpack has Fortran sources but no Fortran compilier found
請參考以下網站完成gfortran的安裝:
http://www.lapk.org/gfortran/gfortran.php?OS=7

然後再回terminal安裝一次,應該就可以快樂安裝成功了。
最後要到IDLE中去check一下才安心:
import scipy
scipy.__version__
=>  '0.16.0'

import sklearn
sklearn.__version__
==> '0.16.1'




沒有留言:

張貼留言