The Python community will stop maintaining Python 2.7 on 1 January 2020. After this date, we expect that there will be no more updates, including no more security fixes, for Python 2.7. Already, an increasing number of core Python packages are providing significant new features only for their Python 3 builds.
Canopy 2.1 is available with installers for Python 2.7 and 3.5. In addition, Python 3.6 is available with all Enthought-built packages, via the Enthought Deployment Manager (EDM), whether standalone, or built into Canopy. See "Canopy 2.1: Managing and switching between Python 2.7 and 3.5 environments".
Porting an existing code base to Python 3 can seem like a huge and scary task, but there are things that can be done while you are still using Python 2.7, that can make it easier to migrate your code to Python 3. Python provides the 2to3 tool to automatically port existing code, but in my experience with it I found that I still had to do a fair bit of by-hand editing and I ended up with 2 sets of code, one for Python 2.7 and one for 3.2+, which just adds more difficulty.
Many of the Python 3 features have been back-ported to Python 2.7 in one way or another, so the best way to reduce porting pain in the future is to write code that is at least mostly compatible with both Python 2.7 and 3.4+ at the same time. It's not too hard to do with new modules and existing modules can usually be migrated over with a few minutes of work. In a nutshell, changing a few things in your coding style and practices now can make the future migration easier. Based on my experience my suggestions are:
- Use all the Py3 "from __future__ import ..." options. The one that had the biggest impact for my code was absolute_import
- Explicitly close() all files when done with them.
- Begin thinking of strings as being different types (unicode or bytes) based on their use, even if they really are the same str type in Python 2.7. In other words, think of all text as unicode objects and all data as bytes objects, and write your code accordingly.
- Use bytes() instead of str() for converting to data. It's just an alias for str now but they will need to be changed for Py3 anyway. Continue to use str() for converting things that are meant to be readable text, not data.
- Use the six module (https://pypi.python.org/pypi/six) or something like it to help smooth out some of the other differences between Py2 and Py3. For example, instead of using "isinstance(obj, basestring)" you can use "isinstance(obj, six.string_types)". It also helps you deal with modules or classes that have changed names or locations in the standard library. Unfortunately it's hard to remember to actually use the things in six until you are using Py3 and are getting errors.
These practices, and a few others that will help write code that is compatible with both Python 2.7 and Python 3, are also discussed in this excellent summary in the Python documentation.
Also see:
- Python 2-3 compatible cheat sheet
- "Supporting Python 3" (book)
- A short guide on features of Python 3 for data scientists (more links at bottom)
- "The Conservative Python 3 Porting Guide"
What is a time frame for a Canopy version built in Python 3? It seems most of the important packages have already moved over. What about building on greater than Python 3.4 since it comes with
pip?
And while I am posting, add rootpy to your package list, please.@wintersun: 1) No timeline yet. 2) VTK, hence Mayavi, have not moved. 3) Rootpy 0.5 is available to subscribers through community repo, or you can install a newer version yourself following the guidelines at https://support.enthought.com/entries/23389761-Installing-packages-into-Canopy-User-Python-from-the-OS-command-line
It's been a while, so I thought I'd ask again. When are we likely to see a release of Canopy built on Python 3? With Guido vowing there will never be a Python 2.8 (We are at 2.7.8, what are they going to do after 2.7.9?) and the upcoming Python 3.5 promising an infix operator for matrix multiplication, the move to Python 3 is becoming urgent.
Seconding what Jonathan Nyquist asked: any updates on canopy built on Python 3?
Intense work continues on the changes to Canopy that will make possible Python 3 support and many other important capabilities. No timeline to announce yet.
Yes - having Python 3 available would be greatly appreciated. Also - a minor thought but having up and down votes like stack overflow might help reduce the amount of comments posted.
An interesting blog post from the PyCon 2015 Language Summit: http://lwn.net/Articles/640181/ . And it's worth noting that one of the packages that has not been migrated to Python 3 is VTK (and hence Enthought's Mayavi which is built on VTK).
Any update on Python 3 support in Canopy?
@DavidJ: As you probably know, VTK is now available for Python 3, which is great news. The next major release of Canopy will support multiple Python platforms, including Python 3. No ETA but not imminent.
Any update on a timescale for a Canopy release which supports Python 3?
Updated with link to excellent new article from Python.org
Any update on the next major release of Canopy (which will support Python 3)?
Python 3.5 is supported in Canopy 2.0, to be released in the next few weeks, and is already supported in the Enthought Deployment Manager (EDM):
Product Description https://www.enthought.com/products/edm/
Documentation http://docs.enthought.com/edm
Download https://www.enthought.com/products/edm/installers/ (6 MB installer)
Overview & Release Notes https://support.enthought.com/hc/en-us/articles/217372346
Is Mayavi available in Canopy 2.0 python 3.5?
Ah, I see that Canopy 2.0 isn't actually available yet :-(
Any news on when it will be released (hopefully with Mayavi)?
@Vitas -- Canopy 2.0.0 is released (phased release, not yet on download page). Replying further on your existing support ticket.
Enthought Python 3.5 has been available for the command line via EDM for several months now. See https://support.enthought.com/hc/en-us/articles/217372346