Sitemap
Manu Ganji

Manu Ganji

Founder, Spreadsheet Converter - https://spreadsheetconverter.co

Installation of Opencv, numpy, scipy inside a virtualenv

2 min readDec 16, 2013

--

source bin/activate 
# or
workon <environment_name>
pip install numpy scipy

Copy globally installed opencv into your virtualenv

cp /usr/lib/pymodules/python2.7/cv* $VIRTUAL_ENV/lib/python2.7/site-packages/

Get Manu Ganji’s stories in your inbox

Join Medium for free to get updates from this writer.

Dependencies

sudo apt-get install cmake libgtk2.0-dev pkg-config libavcodec-dev libavformat-devlibswscale-dev libamd2.2.0 libblas3gf libc6 libgcc1 libgfortran3 liblapack3gf libumfpack5.4.0 libstdc++6 build-essential gfortran libatlas-dev libatlas3-base libblas-dev liblapack-dev libjpeg-dev libpng-dev libtiff-devlibjasper-dev

Download opencv, build it and install it

# change to target directory
cd ~/download_directory
wget -Oopencv-2.4.5.tar.bz2 http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.5/opencv-2.4.5.tar.gz?ts=1371369803&use_mirror=jaist
# unzip
tar xvf opencv-2.4.5.tar.bz2
cd opencv-2.4.5/
mkdir release
cd release
# notice that in the command below,
# -D INSTALL_PYTHON_EXAMPLES=ON
# is optional.
cmake -D MAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=$VIRTUAL_ENV/local/ -D PYTHON_EXECUTABLE=$VIRTUAL_ENV/bin/python -D PYTHON_PACKAGES_PATH=$VIRTUAL_ENV/lib/python2.7/site-packages -D INSTALL_PYTHON_EXAMPLES=ON ..
make -j8
make install

Testing if everything went right

# enter python shell
# make sure your environment is activated
python
import cv
import cv2
import numpy
import scipy
pip freeze | grep Pil # to find the Pillow version we're usingpip -I install Pillow==2.0.0 # or whichever version you find from the step above

--

--