I am unable to get OpenCV to run in python. [closed]

asked 2017-02-20 13:34:49 -0600

Telliott gravatar image

updated 2020-11-17 04:09:22 -0600

I have installed OpenCV and tried to use it in python. I have tried to install it normally and by building it from the source as instructing on the openCV website. These are the errors i am given.

I am unable to attach screenshots of the errors because i am a new member and dont have enough karma so i will type out the errors.

The installation guide I followed

When i try to use "import cv2" in idle python i get the error:

Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> import cv2 ImportError: No module named 'cv2'

And when i try to build from source CMake returns the error:

CMake Error: The source directory "C:/opencv" does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI.

I Cant figure out the problem. Is anyone able to explain why it isnt working and what i need to do to make it work.

Thanks very much>

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by sturkmen
close date 2020-10-12 16:54:09.285219

Comments

I have installed OpenCV and tried to use it in python

what steps did you do, exactly ?

to use cv2.pyd from a prebuild binary package, you should copy it to python/lib/site-packages. did you do that ?

berak gravatar imageberak ( 2017-02-20 13:38:58 -0600 )edit

I did that exactly. I followed the steps at this link multiple times.

http://docs.opencv.org/3.2.0/d5/de5/tutorial_py_setup_in_windows.html (http://docs.opencv.org/3.2.0/d5/de5/t...)

Telliott gravatar imageTelliott ( 2017-02-20 13:42:51 -0600 )edit
1

your link is broken.

added some karma, so you can addlinks/images properly now, but please add that to your question, not in a comment.

berak gravatar imageberak ( 2017-02-20 13:55:31 -0600 )edit

If you get the message ImportError: No module named 'cv2' then basically your python installation is not able to find the cv2 binary for python. Place it in the correct location!

StevenPuttemans gravatar imageStevenPuttemans ( 2017-02-21 04:22:07 -0600 )edit

I copied cv2.pyd into python/lib/site-packages as instructed in the installation guide?

Telliott gravatar imageTelliott ( 2017-02-21 05:56:49 -0600 )edit

you might be having two python installation.. try to remove all python from control panel as well as from the folder where you are pasting cv2.pyd and then create a clean python installation.. try after that

Codacus gravatar imageCodacus ( 2017-02-22 12:36:42 -0600 )edit

@Codacus, how would that be an issue? I have been running python2 and python3 installations next to each other for ages and that works just fine.

StevenPuttemans gravatar imageStevenPuttemans ( 2017-02-25 02:42:31 -0600 )edit

I was having a doubt that you are pasting cv2.pyd in one version of the python and when using python you are running the other version..

Codacus gravatar imageCodacus ( 2017-02-28 09:26:04 -0600 )edit