Showing posts with label ipython. Show all posts
Showing posts with label ipython. Show all posts

Saturday, April 16, 2016

IPython freeze on OpenCV destroyAllWindows

If you are running OpenCV on an IPython console, chances are cv2.destroyAllWindows() will freeze your image window and ultimately kill the kernel. To get around this, intersperse your code with the following functions (startWindowThread() and waitKey(1)) :

cv2.namedWindow('image')
cv2.startWindowThread()
.
.
.
cv2.waitKey(1)
cv2.destroyAllWindows()
cv2.waitKey(1)

Should hopefully solve the issue!

Wednesday, November 5, 2014

How to interrupt Ipython Kernel in Spyder IDE (Anaconda)


In Spyder IDE, the usual interrupt 'Ctrl-C' does not work if you are running your script on an IPython Console. This is because multiple of these consoles are linked to a single kernel. In fact, this message is displayed on the kernel itself :

NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.

To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.

Read more about this, here.


A quick work-around this is to tweak some settings in Spyder:

Go to Run -> Configure. Select Execute in a new dedicated Python console. Check Interact with the Python console after execution.

Now when you run a script, the Interrupt button on the right top of the console should stop the script.

Thursday, October 9, 2014

Useful IPython Notebook Shortcuts

Command Mode Shortcuts

enter: edit mode
shift+enter: run cell
ctrl+enter: run cell, select below
alt+enter: run cell, insert below
y: to code
m: to markdown
t: to raw
1: to heading 1
2: to heading 2
3: to heading 3
4: to heading 4
5: to heading 5
6: to heading 6
up: select previous cell
down: select next cell
k: select previous cell
j: select next cell
ctrl+k: move cell up

Edit Mode Shortcuts
esc: command mode
ctrl+m: command mode
shift+enter: run cell
ctrl+enter: run cell, select below
alt+enter: run cell, insert below
alt+-: split cell
meta+s: save notebook
ctrl+s: save notebook


ctrl+j: move cell down
a: insert cell above
b: insert cell below
x: cut cell
c: copy cell
v: paste cell below
z: undo last delete
d: delete cell (press twice)
shift+m: merge cell below
s: save notebook
meta+s: save notebook
ctrl+s: save notebook
l: toggle line numbers
o: toggle output
shift+o: toggle output
h: keyboard shortcuts
i: interrupt kernel
.: restart kerne