python use opencv get an error -


when use opencv python, error. set environment this:

  1. install python "python-2.7.5.msi"
  2. install numpy "numpy-mkl-1.7.1.win32-py2.7.exe"
  3. install opencv "opencv-python-2.4.6.win32-py2.7.exe"

everything ok. test using following code:

import cv2 img = cv2.imread('lena.bmp') cv2.show('image', img) cv2.waitkey(0) 

but got error follow:

 file "e:\python\cv2.py", line 1, in <module>          import cv2  file "e:\python\cv2.py", line 2, in <module>       img = cv2.imread('lena.bmp')   attributeerror: 'module' object has no attribute 'imread' 

why? when print "import cv2" in idle, didn't error.

well, guess imported file, ie file writing. cause file using name "cv2.py" suggested. you`d better change filename.


Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -