2

so guys after a painful day I have finally gotten opencv to be recognized in python 3 :

Python 3.5.1 (v3.5.1:37a07cee5969, Dec  5 2015, 21:12:44) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.1.0'

but when I do this in Pycharm the result is:

    /Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5 "/Users/saminahbab/Documents/directory/Image Recognition /pictures/searcher.py"
Traceback (most recent call last):
  File "/Users/saminahbab/Documents/directory/Image Recognition /pictures/searcher.py", line 3, in <module>
    import cv2
ImportError: No module named 'cv2'

which could be for a number of reasons, i have tried to do all sorts of symlinks within reason, trying pyenv among others now I know that these are different python builds but I wouldnt know to unify them so as to get cv2 working on pycharm and also keep all of my other packages that I will be using in conjunction. anyone with any advice?

1 Answer 1

1

An easy way to get PyCharm working with OpenCV 3 is as follows:

  1. Install Anaconda to a directory that doesn't require admin access from https://www.continuum.io/downloads
  2. Create a virtual environment (optional):

    conda create -n <yourEnvName> python=<yourPython3Version> anaconda

    source activate <yourEnvName> (source is not required if you are using the anaconda prompt in Windows)

  3. Install OpenCV 3: conda install -n <yourEnvName> -c https://conda.anaconda.org/menpo opencv3

  4. Setup PyCharm: Open PyCharm --> File --> Settings --> Project --> Project Interpreter --> Click on the config wheel, select "Add Local". Add <yourAnacondaDir>\envs\<yourEnvName>\python.exe and wait till PyCharm is done indexing

Finally, create a new python file and check if opencv 3 has been setup properly by typing:

import cv2
print(cv2.__version__)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.