Reputation: 704
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?
Upvotes: 2
Views: 1023
Reputation: 771
An easy way to get PyCharm working with OpenCV 3 is as follows:
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)
Install OpenCV 3: conda install -n <yourEnvName> -c https://conda.anaconda.org/menpo opencv3
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__)
Upvotes: 1