Installing OpenCV in Python 2.7 in Windows with Proper Documentation

Sanpreet Singh
2 min readAug 4, 2018

--

Installing OpenCV in Python 2.7 in Windows with Proper Documentation
Installing OpenCV in Python 2.7 in Windows with Proper Documentation

Python Packages to be installed: Before starting there is need to install Python 2.7 and Numpy where Matplotlib is optional

Installing Python 2.7 for Windows: Python 2.7 can be installed from this link. Please go to the download section and install it. Keep in mind that while installing please add it to the path

Installing NumPy package to windows: You can either use the pip command to install it by typing pip install NumPy in the command prompt or there is another way of downloading wheel files. Let me show you the other way. Please go to this link. Once the required package is downloaded, please install it using the pip command. Please see the below screenshot.

Installing wheel package (Python Distribution)
Installing wheel package (Python Distribution)

Once the above packages are installed, we are ready to download the opencv package. Please visit the following link to download opencv. I have python 2.7 and used OpenCV 3.0 from the list of version. When you have successful in downloading and extracting, final files in the opencv will have the following look.

Sub-folders inside OpenCV
Sub-folders inside OpenCV

Trick: Now it is the time to go for the trick. Please go to the folder build inside the opencv folder. Please approach to python folder and go for 2.7 and finally x64/x86. This depends on your architecture. You will find the file cv2. Please see the below screenshot to understand my statement in broader sense.

cv2 File in OpenCV folder
cv2 File in OpenCV folder

Please copy this file and paste it in the sub-folder site-packages which is inside the folder Lib which is inside the folder Python 2.7. Please see the path from the below screenshot.

Pasting the file cv2 inside the folder site-packages
Pasting the file cv2 inside the folder site-packages

Thanks for finding some time to read this post. Hope images and writing helped you.

Originally published at https://ersanpreet.wordpress.com on August 4, 2018.

--

--

No responses yet