Why Can't I Import Opencv (cv2) In Ipython Notebook?
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.
Solution 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!
Post a Comment for "Why Can't I Import Opencv (cv2) In Ipython Notebook?"