This documentation covers a development version of IPython. The development version may differ significantly from the latest stable release.


This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.

If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).

Module: utils.encoding

Utilities for dealing with text encodings

2 Functions

IPython.utils.encoding.get_stream_enc(stream, default=None)

Return the given stream’s encoding or a default.

There are cases where sys.std* might not actually be a stream, so check for the encoding attribute prior to returning it, and return a default if it doesn’t exist or evaluates as False. default is None if not provided.


Return IPython’s guess for the default encoding for bytes as text.

If prefer_stream is True (default), asks for stdin.encoding first, to match the calling Terminal, but that is often None for subprocesses.

Then fall back on locale.getpreferredencoding(), which should be a sensible platform default (that respects LANG environment), and finally to sys.getdefaultencoding() which is the most conservative option, and usually UTF8 as of Python 3.