I have been struggling to get working OpenCV library for my Python on Mac Snow Leopard, and i think it might be helpful to show how i did it. I am aware that there are many blogs about this issue, and plenty of them are doing the same. I have been reading many blogs about this problem, and i have learned some stuff too, and finally i have done it! I remember being so excited about my first sample actually running…
- Currently the latest version of Python is 3.1.2, but i am using pre-installed 2.6.1. There is nothing wrong with neither version, so go ahead and install it from their download site. They have regular installer for it, so no need to explain anything here…
- Now go and download OpenCV Library from SourceForge download site.
- Unarchive it to some well placed directory… open terminal and navigate there.
While in directory suitable for installing (containing files like CMakeLists.txt or any familiar files containing word “install” in them 😉 ) create folder “release”
mkdir release
and navigate to it
cd release
- Put
ccmake
to the terminal to configure your release. Search for anything including “python” and mark it with YES. You can navigate to next line with ctrl+n and change the setting with Enter. After checking all the options, hit “c” for configure and after that “g” to generate the config file. now you can exit ccmake interface.
- Enter
sudo make -j8
and wait for a while… then
sudo make install
and you are almost there 🙂
- At this point you have installed Python, OpenCV but they might not know about each other… open /etc/bashrc for example with vim and at the end put this
export PYTHONPATH=/path/to/your/OpenCV-2.1.0/release/lib:$PYTHONPATH
export PYTHONPATH=/usr/local/lib/python2.6/site-packages/cv.so:$PYTHONPATH– use versions suitable for you, but make sure you are entering the right folder.
– i have found on web that variable DYLD_LIBRARY_PATH is also important, but i don’t use it and mine works… so in case your library won’t try setting it like the first line of PYTHONPATH variable. - To test if that worked, just type
python
into terminal, and then
import cv
or
import * from opencv
into python console. It should not give you negative feedback about not existing module.
ImportError: No module named cv
go back to point 4 about configuring your OpenCV release and check all values carefully… i had to do it several times… then make and install it again and it should work 🙂
and it was a regular package installation, so i guess you don’t need any assistance there.
Thank you for sharing your info. I truly appreciate your efforts and I will be
waiting for your further write ups thanks once again.