Skip to content

Instantly share code, notes, and snippets.

@HuangFJ
Forked from mitmul/install_opencv2.4.8.sh
Last active November 11, 2021 14:08
Show Gist options
  • Save HuangFJ/5ee1cfe742f442e89917 to your computer and use it in GitHub Desktop.
Save HuangFJ/5ee1cfe742f442e89917 to your computer and use it in GitHub Desktop.
centos 6.5 + opencv 2.4.9 + ffmpeg 0.10.11 + python 2.7.7 自动安装脚本
#! /bin/bash
sudo yum install -y gcc g++ gtk+-devel libjpeg-devel libtiff-devel jasper-devel libpng-devel zlib-devel cmake unzip sqlite-devel readline-devel bzip2-devel openssl-devel ncurses-devel
sudo yum install -y yum-priorities
sudo rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
sudo yum install -y eigen3-devel --enablerepo=epel
su -c 'yum localinstall --nogpgcheck http://download1.rpmfusion.org/free/el/updates/6/i386/rpmfusion-free-release-6-1.noarch.rpm http://download1.rpmfusion.org/nonfree/el/updates/6/i386/rpmfusion-nonfree-release-6-1.noarch.rpm'
sudo yum install -y ffmpeg-devel
export PYTHON_PREFIX=/usr/local/python-2.7.7
wget https://www.python.org/ftp/python/2.7.7/Python-2.7.7.tgz
tar -zxvf Python-2.7.7.tgz
cd Python-2.7.7
./configure --enable-shared --prefix=$PYTHON_PREFIX
make
sudo make install
cd ..
sudo cp $PYTHON_PREFIX/lib/libpython2.7.so.1.0 /usr/local/lib
sudo ln -s /usr/local/lib/libpython2.7.so.1.0 /usr/local/lib/libpython2.7.so
sudo echo '/usr/local/lib' > /etc/ld.so.conf
sudo /sbin/ldconfig
sudo /sbin/ldconfig -v
wget https://raw.github.com/pypa/pip/master/contrib/get-pip.py
$PYTHON_PREFIX/bin/python get-pip.py
$PYTHON_PREFIX/bin/pip install ../requirements.txt -i http://pypi.douban.com/simple
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip
unzip opencv-2.4.9
cd opencv-2.4.9
mkdir build
cd build
cmake ../ -DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DBUILD_EXAMPLES=ON \
-DWITH_EIGEN=ON \
-DBUILD_NEW_PYTHON_SUPPORT=ON \
-DINSTALL_PYTHON_EXAMPLES=ON \
-DPYTHON_EXECUTABLE=$PYTHON_PREFIX/bin/python2.7 \
-DPYTHON_INCLUDE_DIR=$PYTHON_PREFIX/include/python2.7/ \
-DPYTHON_LIBRARY=$PYTHON_PREFIX/lib/libpython2.7.so.1.0 \
-DPYTHON_NUMPY_INCLUDE_DIR=$PYTHON_PREFIX/lib/python2.7/site-packages/numpy/core/include/ \
-DPYTHON_PACKAGES_PATH=$PYTHON_PREFIX/lib/python2.7/site-packages/ \
-DBUILD_PYTHON_SUPPORT=ON
make
sudo make install
@arstropica
Copy link

It's very bad to override the native python binary with another version! Should use make altinstall instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment