Warning
This documentation covers a development version of IPython. The development version may differ significantly from the latest stable release.
Important
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).
7.x Series¶
IPython 7.2.0¶
IPython 7.2.0 brings minor bugfixes, improvements, and new configuration options:
- Fix a bug preventing PySide2 GUI integration from working PR #11464
- Run CI on Mac OS ! PR #11471
- Fix IPython “Demo” mode. PR #11498
- Fix
%run
magic with path in name PR #11499- Fix: add CWD to sys.path after stdlib PR #11502
- Better rendering of signatures, especially long ones. PR #11505
- Re-enable jedi by default if it’s installed PR #11506
- Add New
minimal
exception reporting mode (useful for educational purpose). See PR #11509
Added ability to show subclasses when using pinfo and other utilities¶
When using ?
/??
on a class, IPython will now list the first 10 subclasses.
Special Thanks to Chris Mentzel of the Moore Foundation for this feature. Chris is one of the people who played a critical role in IPython/Jupyter getting funding.
We are grateful for all the help Chris has given us over the years, and we’re now proud to have code contributed by Chris in IPython.
IPython 7.1.0¶
IPython 7.1.0 is the first minor release after 7.0.0 and mostly brings fixes to new features, internal refactoring, and fixes for regressions that happened during the 6.x->7.x transition. It also brings Compatibility with Python 3.7.1, as we’re unwillingly relying on a bug in CPython.
New Core Dev:
- We welcome Jonathan Slenders to the commiters. Jonathan has done a fantastic work on prompt_toolkit, and we’d like to recognise his impact by giving him commit rights. #11397
Notable Changes
- Major update of “latex to unicode” tab completion map (see below)
Notable New Features:
- Restore functionality and documentation of the sphinx directive, which is now stricter (fail on error by daefault), has new configuration options, has a brand new documentation page IPython Sphinx Directive (which needs some cleanup). It is also now tested so we hope to have less regressions. PR #11402
IPython.display.Video
now supportswidth
andheight
arguments, allowing a custom width and height to be set instead of using the video’s width and height. PR #11353- Warn when using
HTML('<iframe>')
instead ofIFrame
PR #11350- Allow Dynamic switching of editing mode between vi/emacs and show normal/input mode in prompt when using vi. PR #11390. Use
%config TerminalInteractiveShell.editing_mode = 'vi'
or%config TerminalInteractiveShell.editing_mode = 'emacs'
to dynamically switch between modes.
Notable Fixes:
- Fix entering of multi-line blocks in terminal IPython, and various crashes in the new input transformation machinery PR #11354, PR #11356, PR #11358. These also fix a Compatibility bug with Python 3.7.1.
- Fix moving through generator stack in ipdb PR #11266
- %Magic command arguments now support quoting. PR #11330
- Re-add
rprint
andrprinte
aliases. PR #11331- Remove implicit dependency on
ipython_genutils
PR #11317- Make
nonlocal
raiseSyntaxError
instead of silently failing in async mode. PR #11382- Fix mishandling of magics and
= !
assignment just after a dedent in nested code blocks PR #11418- Fix instructions for custom shortcuts PR #11426
Notable Internals improvements:
Many thanks to all the contributors and in particular to bartskowron
and
tonyfast
who handled some pretty complicated bugs in the input machinery. We
had a number of first time contributors and maybe hacktoberfest participants that
made significant contributions and helped us free some time to focus on more
complicated bugs.
You can see all the closed issues and Merged PR, new features and fixes here.
Unicode Completion update¶
In IPython 7.1 the Unicode completion map has been updated and synchronized with the Julia language.
Added and removed character characters:
\jmath
(ȷ
),\\underleftrightarrow
(U+034D, combining) have been added, while\\textasciicaron
have been removed
Some sequences have seen their prefix removed:
- 6 characters
\text...<tab>
should now be inputed with\...<tab>
directly,- 45 characters
\Elz...<tab>
should now be inputed with\...<tab>
directly,- 65 characters
\B...<tab>
should now be inputed with\...<tab>
directly,- 450 characters
\m...<tab>
should now be inputed with\...<tab>
directly,
Some sequences have seen their prefix shortened:
- 5 characters
\mitBbb...<tab>
should now be inputed with\bbi...<tab>
directly,- 52 characters
\mit...<tab>
should now be inputed with\i...<tab>
directly,- 216 characters
\mbfit...<tab>
should now be inputed with\bi...<tab>
directly,- 222 characters
\mbf...<tab>
should now be inputed with\b...<tab>
directly,
A couple of characters had their sequence simplified:
ð
, type\dh<tab>
, instead of\eth<tab>
ħ
, type\hbar<tab>
, instead of\Elzxh<tab>
ɸ
, type\ltphi<tab>
, instead of\textphi<tab>
ϴ
, type\varTheta<tab>
, instead of\textTheta<tab>
ℇ
, type\eulermascheroni<tab>
, instead of\Eulerconst<tab>
ℎ
, type\planck<tab>
, instead of\Planckconst<tab>
- U+0336 (COMBINING LONG STROKE OVERLAY), type
\strike<tab>
, instead of\Elzbar<tab>
.
A couple of sequences have been updated:
\varepsilon
now givesɛ
(GREEK SMALL LETTER EPSILON) instead ofε
(GREEK LUNATE EPSILON SYMBOL),\underbar
now gives U+0331 (COMBINING MACRON BELOW) instead of U+0332 (COMBINING LOW LINE).
IPython 7.0.0¶
Released Thursday September 27th, 2018
IPython 7 includes major feature improvements. This is also the second major version of IPython to support only Python 3 – starting at Python 3.4. Python 2 is still community-supported on the bugfix only 5.x branch, but we remind you that Python 2 “end of life” is on Jan 1st 2020.
We were able to backport bug fixes to the 5.x branch thanks to our backport bot which backported more than 70 Pull-Requests, but there are still many PRs that required manual work. This is an area of the project where you can easily contribute by looking for PRs that still need manual backport
The IPython 6.x branch will likely not see any further release unless critical bugs are found.
Make sure you have pip > 9.0 before upgrading. You should be able to update by running:
pip install ipython --upgrade
If you are trying to install or update an alpha
, beta
, or rc
version, use pip --pre
flag.
pip install ipython --upgrade --pre
Or, if you have conda installed:
conda install ipython
Prompt Toolkit 2.0¶
IPython 7.0+ now uses prompt_toolkit 2.0
. If you still need to use an earlier
prompt_toolkit
version, you may need to pin IPython to <7.0
.
Autowait: Asynchronous REPL¶
Staring with IPython 7.0 on Python 3.6+, IPython can automatically await
top level code. You should not need to access an event loop or runner
yourself. To learn more, read the Asynchronous in REPL: Autoawait section of our docs, see
PR #11265, or try the following code:
Python 3.6.0
Type 'copyright', 'credits' or 'license' for more information
IPython 7.0.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import aiohttp
...: result = aiohttp.get('https://api.github.com')
In [2]: response = await result
<pause for a few 100s ms>
In [3]: await response.json()
Out[3]:
{'authorizations_url': 'https://api.github.com/authorizations',
'code_search_url': 'https://api.github.com/search/code?q={query}{&page,per_page,sort,order}',
...
}
Note
Async integration is experimental code, behavior may change or be removed between Python and IPython versions without warnings.
Integration is by default with asyncio
, but other libraries can be configured –
like curio
or trio
– to improve concurrency in the REPL:
In [1]: %autoawait trio
In [2]: import trio
In [3]: async def child(i):
...: print(" child %s goes to sleep"%i)
...: await trio.sleep(2)
...: print(" child %s wakes up"%i)
In [4]: print('parent start')
...: async with trio.open_nursery() as n:
...: for i in range(3):
...: n.spawn(child, i)
...: print('parent end')
parent start
child 2 goes to sleep
child 0 goes to sleep
child 1 goes to sleep
<about 2 seconds pause>
child 2 wakes up
child 1 wakes up
child 0 wakes up
parent end
See Asynchronous in REPL: Autoawait for more information.
Asynchronous code in a Notebook interface or any other frontend using the Jupyter Protocol will require further updates to the IPykernel package.
Non-Asynchronous code¶
As the internal API of IPython is now asynchronous, IPython needs to run under
an event loop. In order to allow many workflows, (like using the %run
magic, or copy-pasting code that explicitly starts/stop event loop), when
top-level code is detected as not being asynchronous, IPython code is advanced
via a pseudo-synchronous runner, and may not advance pending tasks.
Change to Nested Embed¶
The introduction of the ability to run async code had some effect on the
IPython.embed()
API. By default, embed will not allow you to run asynchronous
code unless an event loop is specified.
Effects on Magics¶
Some magics will not work with async until they’re updated. Contributions welcome.
Expected Future changes¶
We expect more internal but public IPython functions to become async
, and
will likely end up having a persistent event loop while IPython is running.
Thanks¶
This release took more than a year in the making. The code was rebased a number of times; leading to commit authorship that may have been lost in the final Pull-Request. Huge thanks to many people for contribution, discussion, code, documentation, use-cases: dalejung, danielballan, ellisonbg, fperez, gnestor, minrk, njsmith, pganssle, tacaswell, takluyver , vidartf … And many others.
Autoreload Improvement¶
The magic %autoreload 2
now captures new methods added to
classes. Earlier, only methods existing as of the initial import were being
tracked and updated.
This new feature helps dual environment development - Jupyter+IDE - where the code gradually moves from notebook cells to package files as it gets structured.
Example: An instance of the class MyClass
will be able to access the
method cube()
after it is uncommented and the file file1.py
is saved on
disk.
# notebook
from mymodule import MyClass
first = MyClass(5)
# mymodule/file1.py
class MyClass:
def __init__(self, a=10):
self.a = a
def square(self):
print('compute square')
return self.a*self.a
# def cube(self):
# print('compute cube')
# return self.a*self.a*self.a
Misc¶
The autoindent feature that was deprecated in 5.x was re-enabled and un-deprecated in PR #11257
Make %run -n -i ...
work correctly. Earlier, if %run
was
passed both arguments, -n
would be silently ignored. See PR #10308
The %%script
(as well as %%bash
,
%%ruby
… ) cell magics now raise by default if the return code of
the given code is non-zero (thus halting execution of further cells in a
notebook). The behavior can be disable by passing the --no-raise-error
flag.
Deprecations¶
A couple of unused functions and methods have been deprecated and will be removed in future versions:
IPython.utils.io.raw_print_err
IPython.utils.io.raw_print
Backwards incompatible changes¶
- The API for transforming input before it is parsed as Python code has been completely redesigned: any custom input transformations will need to be rewritten. See Custom input transformation for details of the new API.