Search code examples
pythonwindowsipythonjupyter-notebookpython-3.4

Print into console terminal not into cell output of IPython Notebook


I would like to print into the terminal window that runs IPython Notebook and not into the cell output. Printing into cell output consumes more memory and slows down my system when I issue a substantial number of print calls. In essence, I would like this behaviour by design.

I have tried the following:

  1. I tried a different permutations of print and sys.stdout.write calls
  2. I looked at the IPython Notebook documentation here, here and here without help
  3. I have tried using this as a workaround but it seems to be only working on Python 2.7

Solution

  • 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.