1

I am getting error

No module named cv2

Can you please guide what command should I type to install CV2 (sudo qpt-get install ..?) Thank you

import numpy as np
import cv2

cap = cv2.VideoCapture('vtest.avi')

while(cap.isOpened()):
    ret, frame = cap.read()

    gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

    cv2.imshow('frame',gray)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()
cv2.destroyAllWindows()
Fahadkalis
  • 2,971
  • 8
  • 23
  • 40
  • 1
    What version of linux are you using? Possible duplicate of http://stackoverflow.com/questions/19876079/opencv-cannot-find-module-cv2 – Paul Lo Dec 22 '14 at 16:51
  • I followed the instructions from here http://docs.opencv.org/trunk/doc/tutorials/introduction/linux_install/linux_install.html – Padraic Cunningham Dec 22 '14 at 17:40
  • @Paul Lo Although my problem has solved but can you please tell me how do i check version of Linux – Fahadkalis Dec 22 '14 at 18:52
  • @Padraic Cunningham I don't know why this one was not working at my side – Fahadkalis Dec 22 '14 at 18:54
  • This article might help: http://unix.stackexchange.com/questions/6345/how-can-i-get-distribution-name-and-version-number-in-a-simple-shell-script – Paul Lo Dec 23 '14 at 02:20

3 Answers3

5

use pip command line:

pip install opencv-python
Ali
  • 3,373
  • 5
  • 42
  • 54
Hawk Rong
  • 165
  • 1
  • 9
2
sudo apt-get install python-openCV
Irshad Bhat
  • 8,479
  • 1
  • 26
  • 36
  • Sorry to ask you incomplete question, both machines are directly connected to each other, and I know the password of my both machines. I want to put all info(host-name, IP, password) in program so that It will not ask for more info during program execution. Thank You – Fahadkalis Dec 22 '14 at 19:07
  • I've posted a solution for this problem where you have asked it. Hole it works for you... – Irshad Bhat Dec 24 '14 at 09:37
0

you can also use conda install cv2:

conda install -c opencv3
Livmortis
  • 121
  • 1
  • 3