2

I installed opencv using macports but Python crashes when I try to use it:

Process finished with exit code 139

My PyCharm IDE indicates that cv2 is a failed module.

Failed modules Python 2.7.1 (/System/Library/Frameworks/Python.framework/Versions/2.7/bin/python) cv2 Generation of skeletons for the modules above will be tried again when the modules are updated or a new version of generator is available

My MacPorts installation of opencv with python 2.7 bindings went smoothly so I'm not sure what could be causing this error. I am assuming that Python is able to import the library, but somehow that the library or its dependencies are failing.

On installation I made sure that numpy was installed first (see: How to install Python 2.7 bindings for OpenCV using MacPorts):

sudo port install opencv +python27

I also made soft links for the dylibs in /usr/local since MacPorts installs them in /opt/local. (see: How to install Python 2.7 bindings for OpenCV using MacPorts)

Community
  • 1
  • 1
user391339
  • 8,355
  • 13
  • 58
  • 71
  • I'm trying to build the source up with CMake now. Maybe there is something wrong with the MacPorts distribution interacting with my OS X 10.7.1 environment. – user391339 Oct 03 '12 at 07:36

1 Answers1

2

I was able to solve the problem by building the source locally instead of using MacPorts.

Download the OpenCV source from http://sourceforge.net/projects/opencvlibrary/

Then follow the directions for CMake build: http://opencv.willowgarage.com/wiki/Mac_OS_X_OpenCV_Port

If you don't have CMake installed, use MacPorts to install it: sudo port install cmake

You need a C++ compiler installed such as Xcode 3.2 or later on MacOSX

In the OpenCV folder,

cmake -G "Unix Makefiles"

Then,

make -j8

sudo make install

Be sure to add /usr/local/lib/python2.7/site-packages to your PYTHONPATH.

Now run the following program:

def main():

 try:
     import cv2
 except ImportError:
     print "cv2 is not installed"
     exit();
 print "looks like its installed "
user391339
  • 8,355
  • 13
  • 58
  • 71