Hi Friends,
Here I will tell you how to install OpenCV 2.4x in Windows for Python 2.7.
Pre-requisites ( need to be downloaded ) :
Python : Download latest version of Python 2.7 from Python site.
Numpy : Download Numpy for Python 2.7 from here.
OpenCV 2.4 : Download OpenCV for windows from here.
Install:
1) First install Python 2.7. Leave all settings as default. In that case, Python will be installed in default folder C:\Python27\
2) Now install Numpy. Again leave everything default. Numpy will find Python directory and will be installed to most appropriate folder.
3) Now double-click OpenCV.exe. It will ask for extraction folder. Give it as just C:\. It will extract all files to C:\opencv\ . Wait until everything is extracted.
4) Now copy everything in the folder C:\opencv\build\python\x86\2.7\ ( most probably, there will be only one file cv2.pyd ) and paste it in the folder C:\Python27\Lib\site-packages\
5) Now open your "Python IDLE" ( from Start > All Programmes > Python 2.7 > Python IDLE ) and just type following :
import cv2
If everything OK, it will import cv2 module, otherwise an error message will be shown.
So it is very simple procedure. Try it yourself and let me know how it goes.
NB : Even if you are using 64-bit windows, do the same procedure. ( Better don't go for 64-bit Python and Numpy )
With Regards,
ARK
Here I will tell you how to install OpenCV 2.4x in Windows for Python 2.7.
Pre-requisites ( need to be downloaded ) :
Python : Download latest version of Python 2.7 from Python site.
Numpy : Download Numpy for Python 2.7 from here.
OpenCV 2.4 : Download OpenCV for windows from here.
Install:
1) First install Python 2.7. Leave all settings as default. In that case, Python will be installed in default folder C:\Python27\
2) Now install Numpy. Again leave everything default. Numpy will find Python directory and will be installed to most appropriate folder.
3) Now double-click OpenCV.exe. It will ask for extraction folder. Give it as just C:\. It will extract all files to C:\opencv\ . Wait until everything is extracted.
4) Now copy everything in the folder C:\opencv\build\python\x86\2.7\ ( most probably, there will be only one file cv2.pyd ) and paste it in the folder C:\Python27\Lib\site-packages\
5) Now open your "Python IDLE" ( from Start > All Programmes > Python 2.7 > Python IDLE ) and just type following :
import cv2
If everything OK, it will import cv2 module, otherwise an error message will be shown.
So it is very simple procedure. Try it yourself and let me know how it goes.
NB : Even if you are using 64-bit windows, do the same procedure. ( Better don't go for 64-bit Python and Numpy )
With Regards,
ARK
I will try later
ReplyDeleteworked perfectly. thanks very much!!
ReplyDeleteThank you! The OpenCV page says there should be a binary download on sourceforge, but it only extracts files. This is exactly what I needed
ReplyDeleteThank you, it works fine, but I still cannot open video files(
ReplyDeleteI'm trying to read it frame by frame, but cv2.VideoCapture(file name).grab() always return false.
None of the programs work though and all give the "cv is not defined error" I am a newbie and help on this will be appreciated !
ReplyDeletewhy cv? All the programmes uses cv2. So use import cv2.
DeleteYou are awesome! Thanks so much for the update. Can't find this anywhere. Saved me a load of frustration!
ReplyDeleteHey Abid,
ReplyDeleteThanks for the post! I tried following your guide and was able to iport cv2. But I was not able to import cv and got an error "No module named cv". Can you help me with this?
Thanks
"import cv" no more supported. Try this instead "import cv2.cv as cv".
DeleteHi,
ReplyDeleteI am getting the following errors trying to install OpenCV 2.4 on Python 2.7 - please help. Thank you!
Traceback (most recent call last):
File "", line 1, in
import cv
ImportError: No module named cv
>>> import cv2
Traceback (most recent call last):
File "", line 1, in
import cv2
ImportError: DLL load failed: %1 is not a valid Win32 application.
>>> import cv2.cv as cv
Traceback (most recent call last):
File "", line 1, in
import cv2.cv as cv
ImportError: DLL load failed: %1 is not a valid Win32 application.
>>> import cv2.pyd as cv
Traceback (most recent call last):
File "", line 1, in
import cv2.pyd as cv
ImportError: DLL load failed: %1 is not a valid Win32 application.
Are you by chance running 64-bit Python? I'm not 100%, but this may be the problem.
DeleteI have the same error, perhaps the problem could be Windows64 :/
DeleteI too am getting the Import Error: DLL load failed: 1% is not a valid Win32 application. I Believe I followed all of your steps correctly though.
ReplyDelete