星期一, 7月 22, 2013

python3.3 easy_install numpy scipy matplotlib 安裝

安裝ptyhon 3.3.2
yum install tk-devel.x86_64
yum install tcl-devel.x86_64
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel
yum install lzma-devel.x86_64 # centos 6.5 不叫這個名字,先不裝看看
yum install xz-devel.x86_64

#上面二個要先裝,不然plot.show()會沒畫面跳出來。
wget http://www.python.org/ftp/python/3.3.2/Python-3.3.2.tar.bz2
tar jxvf Python-3.3.2.tar.bz2
cd Python-3.3.2
export LDFLAGS=-L/usr/lib64;./configure --prefix=/opt/python3 --with-wide-unicode
# 還有,如之後要裝 mod_wsgi (django會用到),那麼記得一定要在configure時加上,--enable-shared
# 還要在編譯時加上-fPIC 不過應該做好--enable-shared設定時就會加上了,如果沒有就export CFLAGS=-fPIC再configure

make
make test
#出現如下錯誤,但似乎不是程式的問題,是不應該用真實存在的網址www.python.org做測試
#所以假裝測這件事…
#FAIL: test_geturl (test.test_urllibnet.urlopenNetworkTests)
#----------------------------------------------------------------------
#Traceback (most recent call last):
#  File "/home/cmd/tmp/python3/Python-3.3.5/Lib/test/test_urllibnet.py", line 86, in test_geturl
#    self.assertEqual(gotten_url, URL)
#AssertionError: 'https://www.python.org/' != 'http://www.python.org/'
#- https://www.python.org/
#?     -
#+ http://www.python.org/

make install
# 有人說要用 make altinstall
# 不知道差異是啥…

#好了之後記得設定路徑
# 因為Centos5已經裝了python2.? 所以我們新裝的請用python3執行

移除先前用yum裝的版本(如果有裝的話)
yum remove python-setuptools.noarch

安裝 setuptools
wget https://bitbucket.org/pypa/setuptools/raw/bootstrap/ez_setup.py 
python3 ez_setup.py
easy_install pip
pip install numpy
cd /opt/python3/lib/python3.3/site-packages/numpy-1.7.1-py3.3-linux-x86_64.egg/numpy/distutils
# 這一段應該不用執行
# 執行 python3 setup.py ,然後輸入下面二行設定c與fortran 編譯器
# gcc
# f<intelem>
# Ctrl-D
新增 site.cfg 檔案,內容如下:
vi /opt/python3/lib/python3.3/site-packages/numpy/distutils/site.cfg
[mkl]
library_dirs = /opt/intel/mkl/lib/intel64
include_dirs = /opt/intel/mkl/include
mkl_libs = mkl_rt
lapack_libs =
透過pip 安裝 scipy 及 matplotlib
先裝 libpng-devel
yum install libpng-devel.x86_64
pip install scipy
pip install matplotlib
# 上面這個如果有X相關的問題(可能是遠端ssh 有x-tunnel沒開X serv),

安裝Module netCDF4 假設我們已經裝好hdf5在 /usr/local/hdf5及netcdf4在/usr/local/netcdf 中
export HDF5_DIR=/usr/local/hdf5
export NETCDF4_DIR=/usr/local/netcdf
export USE_NCCONFIG=1
pip install netcdf4
安裝basemap
yum install agg.x86_64
# geos 必需3.?版以上與 proj 與 ,所以另外增加第三方套件庫,
wget http://apt.sw.be/redhat/el5/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm
wget http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el6.rf.x86_64.rpm
#註,請自行連上網去看,上面的/rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm 檔案有無更新的版本。
rpm -Uvh rpmforge-release-0.5.3-1.el5.rf.x86_64.rpm
yum install proj-devel.x86_64
yum install geos-devel.x86_64
# yum install geos-python.x86_64 <--不用?

pip install pillow
pip install pytz
pip install python-dateutil
easy_install basemap
# 在用到PIL套件時如果遇到此類錯誤
#decoder jpeg not available
#就是沒裝libjpeg
#要裝上它(CentOS6.5是如下套件)
yum install libjpeg-turbo-devel.x86_64
#完了之後要重新裝PIL及相關套件(Python2版)在python3中叫做Pillow
pip install -I Pillow
pip install -I pytz
pip install -I python-dateutil
# 
easy_install -mxN basemap
easy_install basemap
# 這次在CentOS6.5的機器上,一直沒有辦法把basemap裝好,
#感覺是GEOS的問題,試了好久,只好編譯basemap裏面附的geos版本
# 編譯好之後再手動setup basemap,步驟如下
# 下載 basemap-1.0.7.tar.gz 並且 tar zxvf
# src 資料夾裏有一個 geos-3.3.3
./configure --prefix=/usr/local/geos
make; make install
export GEOS_DIR=/usr/local/geos
cd ../
python3 setup.py install
# 搞定
安裝ipython
#先安裝zeromq 套件,網站建議用yum,所以要把該網站的repo放到/etc/yum.repos.d/中
#cd /etc/yum.repos.d/
#wget http://download.opensuse.org/repositories/home:/fengshuo:/zeromq/CentOS_CentOS-5/home:fengshuo:zeromq.repo
# 6.5 版直接不用做上面的步驟
yum install zeromq-devel.x86_64
pip install tornado
pip install pyzmq
pip install ipython

沒有留言: