Importing OpenCV with python 2.7 in Virtualenv and PyCharm
Question: I am struggling with installing opencv for python 2.7.11 on OSX for almost
three days now.

After some failures, I accomplished a first success by following the
instructions [here](http://www.pyimagesearch.com/2015/06/15/install-
opencv-3-0-and-python-2-7-on-osx/). So my basic setup is python 2.7.11 running
from `~/.virtualenvs/cv_env/bin/python` and I have a `cv2.so` located in
`~/.virtualenvs/cv/lib/python2.7/site-packages/`.

So good so far. Using `source ~/.virtualenvs/cv_env/bin/activate`, I can
activate the virtualenv and than use `import cv2`. For some reasons, this does
not work always. From time to time, I have to deactivate first and than
reactivate (any guesses?).

Next, I wanted to use opencv in PyCharm. Under "preferences - Project
interpreter", I selected the virtualenv interpreter and this is also working.
I can import other moduals like numpy and pandas (previously installed into
the vortualenv using `pip`). But for some reasons, I am not able to import
opencv (`import cv2`). It always gives me

`ImportError: No module named cv2`

So my question is, why I am able to import opencv in terminal (at least
sometimes) but not in PyCharm. Any ideas are welcomed.

Best, Fabian


Answer: Your `cv2.so` located in a different directory. And you activating from
another directory. I mean `cv_env` and `cv`.

