Print into console terminal not into cell output of IPython Notebook
On Windows, this can work:
import sys
sys.stdout = open(1, 'w')
You have to redirect your output to the systems standard output device. This depends on your OS. On Mac that would be:
import sys
sys.stdout = open('/dev/stdout', 'w')
Type the above code in an IPython cell and evaluate it. Afterwards all output will show up in terminal.
In order to be able to switch form one to the other easily:
terminal_output = open('/dev/stdout', 'w')
print('this will show up in the IPython cell output')
print('this will show up in the terminal', file=terminal_output)
Similarly, terminal_error = open('/dev/stderr', 'w')
can be used to send to the terminal stderr, without any conflict with the default behavior of sys.stderr
(which is to print an error message in the IPython cell output).