I am running Mac OS X 10.11 (El Capitan). I want to:
I installed pyenv
and Python 3.5 by following this SO answer: https://stackoverflow.com/a/18671336/1410871
I activated my Python 3 installation and installed OpenCV 3 with Python 3 support like this:
pyenv shell 3.5.0
brew install opencv3 --with-python3
But when I launch an IPython shell and import cv2
, I get an error:
ImportError Traceback (most recent call last)
<ipython-input-1-72fbbcfe2587> in <module>()
----> 1 import cv2
ImportError: No module named 'cv2'
why?
Answering my own question: I have to manually create a symlink to the shared object file and place it in the pyenv Python 3 site-packages directory:
ln -s /usr/local/opt/opencv3/lib/python3.5/site-packages/cv2.cpython-35m-darwin.so ~/.pyenv/versions/3.5.0/lib/python3.5/site-packages/cv2.so
Now the line import cv2
works as expected in Python.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With