Search code examples
pythonmacosopencvcomputer-visionenthought

How to Install openCV into Enthought python distribution on Mac


Edit: Okay, I've generalized the question more in hopes that I get an answer. All I care about in the end is somehow installing openCV into the Enthought python distribution on a Mac computer. Any help would be greatly appreciated, the scripting isn't beyond me, but I don't have enough understanding of computer programming to figure out what these parameters mean and what needs to be different from Linux vs mac.

Hint: I've been following the guidelines found on this website, but it's for Linux and it fails 95% into the "make" command: http://pyetc.wordpress.com/2013/01/09/installing-the-enthought-python-distribution-with-opencv/

export EPDPATH=$HOME/.local/epd-7.3-2-rh5-x86_64
# prepend the EPD bin dir to your path to make your shell prefer the EPD python interpreter to the system python interpreter
export PATH=$EPDPATH/bin:$PATH
# also the python packages should be searched in the correct location
export PYTHONPATH=$EPDPATH/lib/python2.7/site-packages

Followed by:

mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX:PATH=$HOME/.local -D PYTHON_EXECUTABLE:FILEPATH=$EPDPATH/bin/python -D PYTHON_INCLUDE_DIR:PATH=$EPDPATH/include/python2.7 -D PYTHON_LIBRARY:FILEPATH=$EPDPATH/lib/libpython2.7.so -D PYTHON_LIBRARY_PATH:UNINITIALIZED=$EPDPATH/lib/libpython2.7.so -D PYTHON_NUMPY_INCLUDE_DIR:PATH=$EPDPATH/lib/python2.7/site-packages/numpy/core/include -D PYTHON_PACKAGES_PATH:PATH=$EPDPATH/lib/python2.7/site-packages -D SPHINX_BUILD:FILEPATH=$EPDPATH/bin/sphinx-build -D PYTHONINTERP_FOUND=1 -D BUILD_PYTHON_SUPPORT=ON -D INSTALL_PYTHON_EXAMPLES:BOOL=ON ..
make
make install

Solution

  • Although I don't have an exact answer to your question, I do suppose I have a solution to your problem. Coincidently I struggled yesterday with installing OpenCV on my mac as well. I finally simply did it by installing python and opencv using macports. That way you don't have opencv in the enthought distro, but you can simply install all the packages you use in the enthought distro using macports.

    So just install macports from this page: http://www.macports.org/install.php

    Then do:

    sudo port install python27 # (or any other version you want)
    sudo port install py27-numpy
    sudo port install opencv +python27
    

    and of course you can install any other packages you need:

    sudo port install py27-scipy 
    sudo port install py27-ipython
    etc.
    

    Finally, you have to make sure that when typing "python" on the command line, it does refer to the version thatyou installed using macports. You can do this by editing your ~/.bash_profile like so:

    sudo open -t ~/.bash_profile
    

    Once it has opened just see if there are references to other python distro's. You most likely have a reference to your Enthough version in there. Comment out all other python versions and add the following line:

    export PATH=/opt/local/bin:/opt/local/sbin:$PATH
    

    That should do the trick: having opencv working with python while still having all the scientific modules that you like.

    Cheers!