0

Whenever I run

import cv2

in an IPython notebook cell, I get an error screen with the message

 Kernel Restarting
 The kernel appears to have died. It will restart automatically.

Then another dialog stating python quit unexpectedly. Does this mean I cannot run OpenCV in IPython? I cannot seem to find the solution to this anywhere by googling.

Is there a solution to this problem?

Platform: Mac OSX:10.9, IPython 4.0.3, Python 2.7.9

Thomas K
  • 39,200
  • 7
  • 84
  • 86
Ébe Isaac
  • 11,563
  • 17
  • 64
  • 97

1 Answers1

1

The slight variant of the solution to this post solved my problem.

The actual python shell that was used by my terminal and many other applications that used OpenCV's cv2 properly was obtained by

which python

in the Terminal. It returned /opt/local/bin/python

The executable for IPython was located in /usr/local/bin/ipython -- Open it (it may require superuser privileges)

sudo nano /usr/local/bin/ipython

You'd find that the first line of the file is #!/usr/bin/python which causes ipython to execute the default compiler. This had to be replaced with the line #!/opt/local/bin/python.

Then the problem was fixed. I started the IPython notebook as usual and executed import cv2 and it went well without a glitch!

Community
  • 1
  • 1
Ébe Isaac
  • 11,563
  • 17
  • 64
  • 97