I spent the past couple of days trying to get opencv to work with my Python 2.7 install. I kept getting an error saying that opencv module was not found whenever I try \"import
You need to install the module using your python2.7 installation. Pointing your PYTHONPATH at stuff installed under 2.6 to run under 2.7 is a Bad Idea.
Depending on how you want to install it, do something like python2.7 setup.py
or easy_install-2.7 opencv
to install.
fwiw, on OS X the modules are usually installed under /System/Library/Frameworks/Python.framework/ but you should almost never need to know where anything installed in your site packages is physically located; if Python can't find them without help you've installed them wrong.
I spent a couple days on this myself. For me, the problem was that that OpenCV installer was not finding the right python installation. It was defaulting to the MacOS-installed version despite the fact that I had upgraded python with homebrew and was using a virtualenv for python. I have collected most of my setup in a gist here: https://gist.github.com/4150916
Use homebrew to get all the dependencies, but then download the OpenCV tarball and compile yourself being sure to specify all the python related configuration options.
Assuming a virtualenv named 'opencv'...
cd OpenCV-2.4.3/
mkdir release
cd release
cmake -D PYTHON_EXECUTABLE=$WORKON_HOME/opencv/bin/python \
-D PYTHON_PACKAGES_PATH=$WORKON_HOME/opencv/lib/python2.7/site-packages \
-D INSTALL_PYTHON_EXAMPLES=ON\
-D PYTHON_INCLUDE_DIR=/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Headers\
-D PYTHON_LIBRARY=/usr/local/Cellar/python/2.7.3/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib\
..
make -j8
make install
I searched and tried installing opencv3 with python3 for 3 days. Some links suggest for Brew and some virtual env, some say install xcode but all failed in my case. Dont use linux steps to instal opencv-python on Mac. Problem with Mac is Python 2.7 is already installed by Mac. On top of that installing and linking all site-packages is little problematic and we end up with errors.
I'll share what I did: easy steps to install complete package opencv3, numpy, matplotlib, notebook, spyder etc.. on Mac.
Install anaconda, it creates a directory and install everything inside that use this link -> https://www.continuum.io/downloads download command-line-install
After download, goto terminal and download location of anaconda. $ bash Anaconda3-4.3.0-MacOSX-x86_64.sh
Installation will ask you to append path to .bash_profile >> say yes
Goto home directory, run .bash_profile $ source .bash_profile
check python, should be pointing to $ which python $ /.../anaconda/bin/python
Last step $ pip install opencv-pyhton
$ python
$ import cv2
if no errors, we are good to go.
brew tap homebrew/homebrew-science
brew install opencv
Depending on your install location - OS X Default
cd /Library/Python/2.7/site-packages/
or - Homebrew Python
cd /usr/local/lib/python2.7
Then create the symbolic link
ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv.py cv.py
ln -s /usr/local/Cellar/opencv/2.4.9/lib/python2.7/site-packages/cv2.so cv2.so
The above method sourced from a blog post.