Fix IPython detection.  Fix encoding error on Python 3
Remove _in_ipython
Merge pull request #2834 from mdboom/webagg/ipython-detection

WebAgg: Fix IPython detection.  Fix encoding error on Python 3