基础套餐
yum update
yum groupinstall "Development Tools"
1.升级python到2.7.3
1.1 查看版本,确认是否需要升级
python -V
1.2 下载Python-2.7.3
wget http://python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
1.3 解压Python-2.7.3
tar -jxvf Python-2.7.3.tar.bz2
1.4 编译安装
cd Python-2.7.3
./configure
make all
make install
make clean
make distclean
source /etc/profile
python -V #查看是否已升级到正确版本
2 安装pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
python get-pip.py
3 安装opencv
3.1 安装依赖库
yum install numpy opencv*
3.2 安装opencv
pip install numpy opencv-python
4 安装dlib
4.1 升级gcc到版本4.9.2
4.1.1 下载源码并解压
sudo yum install libmpc-devel mpfr-devel gmp-devel 安装依赖
curl ftp://ftp.mirrorservice.org/sites/sourceware.org/pub/gcc/releases/gcc-4.9.2/gcc-4.9.2.tar.bz2 -O
tar xvfj gcc-4.9.2.tar.bz2
4.1.2 编译安装
cd gcc-4.9.2
./configure --disable-multilib --enable-languages=c,c++
make && make install
source /etc/profile
4.2 安装dlib
##安装boost
yum install boost boost-devel boost-doc
#安装cmake,编译dlib需要用到
yum install cmake
#由于dlib默认指定的是/usr/bin/cc和/usr/bin/c++来编译,而我们的gcc-4.9.2安装的目录是/usr/local/bin/
#所以需要把/usr/local/bin/cc和/usr/local/bin/c++软连接到/usr/bin/cc和/usr/bin/c++
#备份
mv /usr/bin/cc /usr/bin/cc4.4.7
mv /usr/bin/c++ /usr/bin/c++4.4.7
#建立软连接
ln -s /usr/local/bin/cc /usr/bin/cc
ln -s /usr/local/bin/c++ /usr/bin/c++
pip install dlib
###若出错c++: internal compiler error: Killed (program cc1plus)则执行
dd if=/dev/zero of=/var/swap.img bs=1024k count=1000
mkswap /var/swap.img
swapon /var/swap.img
4.3 修改库的软连接
#此时运行脚本还是会报错 ImportError: /usr/lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /usr/local/lib/python2.7/site-packages/dlib/dlib.so
#这是由于读了旧的库,用软连接将库连接到新的
mv /usr/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6.old
ln -s /usr/local/lib64/libstdc++.so.6 /usr/lib64/libstdc++.so.6