centos6.3搭建numpy,scipy,matplotlib,OpenCV,mlpy的实录

centos6.3搭建numpy,scipy,matplotlib,OpenCV,mlpy,PIL的实录


-------------------------------------------------------
预备环境:
[root@localhost ~]# lsb_release -a
LSB Version: :core-4.0-amd64:core-4.0-noarch:graphics-4.0-amd64:graphics-4.0-noarch:printing-4.0-amd64:printing-4.0-noarch
Description: CentOS release 6.3 (Final)
[root@localhost ~]# g++ --version
g++ (GCC) 4.4.6 20120305 (Red Hat 4.4.6-4)
[root@localhost ~]# gcc --version
gcc (GCC) 4.4.6 20120305 (Red Hat 4.4.6-4)
[root@localhost ~]# python --version
Python 2.6.6

保持联网

python的setup.py文件及其常用命令,请参考:
http://www.2cto.com/kf/201209/153517.html

-----------------------------------------------------
首先使用yum安装系统自带的包

yum -y install python-devel python-scipy python-matplotlib
yum -y install atlas atlas-devel atlas-static
yum install -y gsl
easy_install Cython
-----------------------------------------------------
准备好需要编译源码再安装的包:
numpy-1.8.1.tar.gz
scipy-0.14.0.tar.gz
OpenCV-2.4.4a.tar.bz2
mlpy-3.4.0.tar.gz
Imaging-1.1.7.tar.gz
-----------------------------------------------------
安装numpy-1.8.1的步骤:
cd numpy-1.8.1
updatedb
locate atlas|egrep -i "include|lib"|egrep -v "yum|share|src"
查找到atlas库所在的目录为 /usr/lib64/atlas
atlas库头文件所在 :/usr/include/atlas
cp site.cfg.example site.cfg
vim site.cfg
74 [atlas]
75 library_dirs = /opt/atlas/lib
76 include_dirs = /opt/atlas/include
修改为
74 [atlas]
75 library_dirs = /usr/lib64/atlas
76 include_dirs =
python setup.py install
------------------------------------------------------
安装scipy-0.14.0.tar.gz 的步骤:
tar zxvf scipy-0.14.0.tar.gz
cd scipy-0.14.0
cp site.cfg.example site.cfg

vim site.cfg
修改[Default]成
58 #[DEFAULT]
59 #library_dirs = /usr/local/lib
60 #include_dirs = /usr/local/include
末尾添加
[atlas]
library_dirs = /usr/lib64/atlas
include_dirs = /usr/local/include
python setup.py install
---------------------------------------------------------
安装mlpy-3.4.0.tar.gz的步骤:
tar zxvf mlpy-3.4.0.tar.gz
cd mlpy-3.4.0
python setup.py install
等待大约25分钟,编译安装完成。
安装Imaging-1.1.7.tar.gz的步骤:
---------------------------------------------------------
安装Imaging-1.1.7.tar.gz的步骤:
tar zxvf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7
python setup.py install
---------------------------------------------------------
安装OpenCV-2.4.4a.tar.bz2的步骤:
tar jxvf OpenCV-2.4.4a.tar.bz2
cd opencv-2.4.4/
mkdir build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=./build ../opencv-2.4.4/
make
大约等待30分钟
cd modules/python/
make
make install

[root@localhost opencv-2.4.4]# ll build/lib/python2.6/site-packages/
total 1596
-rwxr-xr-x. 1 root root 1629463 Aug 13 12:01 cv2.so
-rw-r--r--. 1 root root 43 Aug 13 12:35 cv.py

cp -r build/lib/python2.6/site-packages/*.* /usr/lib64/python2.6/site-packages/

加载动态库
mkdir /usr/lib64/opencv2
cp -r build/lib* /usr/lib64/opencv2
[root@localhost site-packages]# ll /etc/ld.so.conf.d/
total 32
-rw-r--r--. 1 root root 17 Aug 13 13:20 atlas-x86_64.conf
[root@localhost site-packages]# vim /etc/ld.so.conf.d/atlas-x86_64.conf
/usr/lib64/atlas
[root@localhost site-packages]# vim /etc/ld.so.conf.d/opencv-x86_64.conf
/usr/lib64/opencv2

然后ldconfig



切换到不是python源码所在的目录,比如上级目录,进行一下测试:


[root@localhost packages]# python
Python 2.6.6 (r266:84292, Jun 18 2012, 14:18:47)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> print numpy.__version__
1.8.1
>>> import mlpy
>>> print mlpy.__version__
3.4.0
>>> import scipy
>>> print scipy.__version__
0.14.0
>>> import matplotlib
>>> print matplotlib.__version__
0.99.1.1
>>> import Image
>>> import cv
>>> print cv.__file__
/usr/lib64/python2.6/site-packages/cv.pyc

你可能感兴趣的:(机器学习,NLP)