It is with great pleasure that today we released IPython 6.0 — almost a year after the 5.0 version.
Users on Python 3.3 and above can get this latest version with all its new features by asking your package manager to upgrade IPython. If you are using pip:
Ensure you have pip 9+:
if not upgrade pip:
pip install pip --upgrade
Then upgrade IPython.
pip install ipython --upgrade
or if you have conda:
conda update ipython
It might take a few hours/days for the various conda channels to be updated.
The What's New page has an extensive description of the changes, which includes new, modified and deprecated features.
Highlighted feature: Jedi completion
One of the biggest changes is integration with Jedi, which provides completions using static analysis, and can display completion types. This will provide a foundation for a richer tab completion experience (e.g., it allows extracting and displaying function signatures in the completer). As of now, these features are available only for command line users, but work is underway in IPykernel and in various frontends (like nteract) to make use of these features.
Sunsetting Python 2 support
As we announced last year when we released IPython 5.0, IPython 6 and above require Python 3. The 5.x branch is still maintained and will be regularly released, so Python 2 users will still see updates, but new features in IPython 6.x will not be backported.
We have worked to make installing IPython on Python 2 and 3 as seamless as possible, but you may still encounter errors. If you do, please check the readme on Github.
If you want to hear more about the process of creating a seamless Python 2 sunset and are planning on attending PyCon 2017, we encourage you to attend our talk “Ending Py2/Py3 compatibility in a user friendly manner” on Saturday, May 20, 2017 at 15:15–16:00 PDT.
Make sure you have Pip 9 or above
For most end users the only thing you should pay attention is to have pip version 9, or above. To check your pip version, run:
If you have a version of pip older than 9.0.1, you should upgrade pip to its latest version before upgrading ipython **:
pip install pip --upgrade
Pip 9+ will install the latest compatible version of IPython – that is to say IPython 5.x if you are on Python 2, and IPython 6.x if you are on Python 3. Make sure this is the case for all your Python environments, and build scripts. Users of Ubuntu Trusty 14.04 LTS should be aware that the default pip is too old and will not install the correct version of IPython. Don’t forget to upgrade pip in your various install script, continuous integration settings and docker images.
The Python 3 statement
We care deeply about the seamless coexistence of Python 2 and Python 3 software. This is one of the reasons we started this transition with a new release that is only available for Python 3, while still maintaining the 5.x release series, which is compatible with Python 2. If you want to read more about these reasons you can find more information at the python 3 statement.
As expected, we discovered many challenges and pitfalls as we moved from a single source to a Python3-only source. In the course of overcoming these obstacles, we learned a great deal. We have documented the the risks and errors you can encounter (and their solutions) at the practicalities section of the python 3 statement.
If you are a library maintainer planning to stop support for an older version of Python (even a minor version), and you want to limit the frustration faced by users who use your library on the older version of Python, we could use your help! If you want to add to the resources available for trouble-shooting this transition, please join the conversation on our GitHub repository.
Migrating to Python3-only source
The migration of the IPython source code to be Python3-only was not an easy task, and was – as far as we can tell – unexplored territory. But we’ve bitten the bullet and hopefully anticipated most of the problems that can arise. With this, we hope to make the transition easier for other projects who want to follow our lead.
First, let’s speak about our personal experience writing Python3-only source code.
The size of the IPython codebase has decreased by about 1500 lines of Python code relative to the last release. Of course, that’s not solely due to the removal of Python 2 support, but a non-negligible amount is. And this reduction is even more remarkable in light of completely new features that required adding hundreds of lines of code. A large number of conditionals are gone, making the code more straightforward, easier to read, and simpler to maintain. Across the codebase we saw improvements in code compactness just from removing utility functions that existed only to provide identical behavior across Python 2 and Python 3. Even then, parts of the codebase remain affected by “Python 2 code”, so the potential gains are even greater. We will continue our quest to remove things as we go, and, as usual, contributions are welcome.
This change eases the burden on contributors to IPython. Contributors can can spend less time thinking “what about Python 2”, or rewriting a pull request because the Python 2 test suite fails. At the same time, our tests now complete more quickly on continuous integration services because they need to run on fewer versions of Python.
A couple of new APIs are using type annotations, Python3-only syntax which, properly used, make the code clearer and easier to refactor, and allow the documentation to focus on usage / reason than to describe the types of the function. We can also make use of nifty Python 3 features like keyword-only arguments, which is definitely appreciated when designing APIs.
From a developer point of view we are extremely pleased with having the possibility to write Python3-only code, and are looking forward to even more improvements like pathlib.
Keeping a Python 2 stable branch
Keeping a Python 2 stable branch, and making the install experience as seamless as possible for Python 2 users was a key point in our decision to migrate to requiring Python 3. One of our first questions was how could we make sure that Python 2 users using
pip install would get the latest 5.x version of IPython still compatible with their system (and not the latest >6.x version that would not be compatible)? This lead us to a number of upstream patches (we’re giving a talk at PyCon, come see us) and a number of guides as to how to make the transitions as a seamless as possible. We patched pip, pypi-legacy, warehouse (we had to learn postgres for that one), amended peps and made use of recent improvements in setuptools to allow Python users to peacefully coexist. The only thing the user should need to do is to make sure to use
pip 9+ , and to use
pip install . and
pip install -e . instead of invoking
Migrating more code to Python3-only
IPython is the first of the Python packages we maintain which has been migrated from Python 2+3 compatibility to requiring Python 3. Some of our more recent projects (like JupyterHub) have required Python 3 from their beginnings. We expect more Jupyter & IPython projects will move to requiring Python 3 in the future.
As the Jupyter protocol is language agnostic, it is perfectly possible to run Python 2 code in a Python 2 kernel using a Notebook Server running on Python 3. Especially since JupyterHub already requires Python 3, we envisage that the single-user notebook server will follow suit soon.
We hope you will enjoy this release. It will be the base for some awesome features, like async/await REPL. We hope our work in the packaging ecosystem will minimise the inevitable teething difficulties from our first release to require Python 3. We look forward for your feedback.