Search code examples
jupyter-notebookhachoir-parser

jupyter-notebook output for loop not showing


When i run my Jupyter-notebook with python2.7 and try to print items (of a list) using a for-loop it just won't output the print statement after importing the following packages:

import sys
import os
from hachoir_core.cmd_line import unicodeFilename
from hachoir_metadata import extractMetadata
from hachoir_parser import createParser
from hachoir_core.i18n import getTerminalCharset
from hachoir_core.tools import makePrintable
import pandas as pd

example code:

items = [1, 3, 0, 4, 1]
for item in items:
   print (item)

output is blank.

When I use the exact same code before importing, it does show.

Looks like hachoir imports are the problem, whenever I import anything containing it, the output stops showing.


Solution

  • Reposting as an answer: The hachoir_metadata module appears to do something odd with stdout which breaks IPython: Bug report.

    As described in that link, you need to add the following code before importing hachoir_metadata:

    from hachoir_core import config
    config.unicode_stdout = False