I am working on a project that requires OpenCV and I am doing it in PyCharm on a Mac. I have managed to successfully install OpenCV using Homebrew, and I am able to import cv2 when I run Python (version 2.7.6) in Terminal and I get no errors. The issue arises when I try importing it in PyCharm. I get a red underline with:
no module named cv2
I assume that PyCharm is unable to locate my cv2.so file but I have the latest PyCharm version (4.0.6) and none of the forums I've looked at are helpful for this version. How do I get PyCharm to recognise my cv2 file? I went in Project Interpreter but there is no option for importing OpenCV from my own machine. Furthermore in Edit Configurations I defined an environment variable
PYTHONPATH
and set it to
/usr/local/lib/python2.7/site-packages:$PYTHONPATH
but this didn't help either.
Any ideas?
EDIT: I set up a virtualenv to no avail and figured out how to add a path to the current framework on the new PyCharm version and it turns out the path to cv2.so has already been given yet it is still complaining.
cv2
appear in the list of installed packages in Project Interpreter? Have you tried adding it though that view (see e.g. jetbrains.com/pycharm/help/…)? Do you have multiple interpreters on your machine (e.g. are you usingvirtualenv
s)? – jonrsharpe:$PYTHONPATH
is required. only/usr/local/lib/python2.7/site-packages
in PYTHONPATH. – Youngjae