平臺:Linux version 2.6.32-220.13.1.el6.x86_64 (mockbuild@c6b6.bsys.dev.centos.org) (gcc version 4.4.6 20110731 (Red Hat 4.4.6-3) (GCC) ) #1 SMP Tue Apr 17 23:56:34 BST 2012
具體過程:
安裝BLAS:
mkdir -p ~/src/
cd ~/src/
wget http://www.netlib.org/blas/blas.tgz
tar xzf blas.tgz
cd BLAS
## NOTE: The selected fortran compiler must be consistent for BLAS, LAPACK, NumPy, and SciPy.
## For GNU compiler on 32-bit systems:
#g77 -O2 -fno-second-underscore -c *.f # with g77
#gfortran -O2 -std=legacy -fno-second-underscore -c *.f # with gfortran
## OR for GNU compiler on 64-bit systems:
#g77 -O3 -m64 -fno-second-underscore -fPIC -c *.f # with g77
gfortran -O3 -std=legacy -m64 -fno-second-underscore -fPIC -c *.f # with gfortran
## OR for Intel compiler:
#ifort -FI -w90 -w95 -cm -O3 -unroll -c *.f
# Continue below irrespective of compiler:
ar r libfblas.a *.o
ranlib libfblas.a
rm -rf *.o
export BLAS=~/src/BLAS/libfblas.a
安裝Lapack:
mkdir -p ~/src
cd ~/src/
wget http://www.netlib.org/lapack/lapack.tgz
tar xzf lapack.tgz
cd lapack-*/
cp INSTALL/make.inc.gfortran make.inc # on Linux with lapack-3.2.1 or newer
#這里要修改下make.inc中的一些內(nèi)容
#FORTRAN = gfortran
#OPTS = -O2 -frecursive -m64 -fPIC
#DRVOPTS = $(OPTS)
#NOOPT = -O0 -frecursive -m64 -fPIC
#LOADER = gfortran
#LOADOPTS =
#以上是我安裝成功時的參數(shù)
make lapacklib
make clean
export LAPACK=~/src/lapack-*/libflapack.a
下載scipy包顽冶,解壓,進入目錄
python setup.py install --prefix=YourDir
成了:-)
問題與解決方案:
1)老問題动羽,權(quán)限不足
解決方案:
修改PATH句喷。
這次還遇上了GCC調(diào)用服務(wù)器默認庫镣典,無法找到賬戶上的python2.7,所以查到GCC庫文件導(dǎo)入的方法,還有頭文件導(dǎo)入方法,一并記錄下吧
# include head file when compiling c
C_INCLUDE_PATH=YourDir
export C_INCLUDE_PATH
#include head file when compiling c++
CPLUS_INCLUDE_PATH=YourDir
export CPLUS_INCLUDE_PATH
#import lib diractory
LIBRARY_PATH=YourDir
export LIBRARY_PATH
參考:http://stackoverflow.com/questions/7496547/python-scipy-needs-blas