This looks like http://emacs.stackexchange.com/questions/24453/weird-shell-output-when-using-ipython-5, but it actually is not. I did set 

 (setq python-shell-interpreter-args "--simple-prompt -i --pylab")
in .emacs, but I get the following error:


 Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
 Type "copyright", "credits" or "license" for more information.

 IPython 5.1.0 -- An enhanced Interactive Python.
 ? -> Introduction and overview of IPython's features.
 %quickref -> Quick reference.
 help -> Python's own help system.
 object? -> Details about 'object', use 'object??' for extra details.
 Using matplotlib backend: TkAgg
 Warning: disable autoreload in ipython_config.py to improve performance.

 In [1]: 
 In [2]: 
 In [3]: 
 In [4]: for i in reange(3):
 File "<ipython-input-4-658181e351fb>", line 1
 for i in range(3):
 ^
 SyntaxError: unexpected EOF while parsing

This appears after I hit return. I was expecting the interpreter to wait for the content of the loop. Note that if I do not set the python-shell-interpreter-args, the prompt is garbage, but there is no error.