Python 3 is not backwards compatible with Python 2, so your code may need to be adapted.

Please start migrating your existing your existing Python 2 code to Python 3.

Python 2 series End Of Life is set to 1st of January 2020.

Introduction

Python 2.7 was released on July 2010. Being the last of the 2.x series, 2.7 has had an extended period of maintenance. Specifically, 2.7 will receive bugfix support until January 1, 2020. After the last release, 2.7 will receive no support. 

Python 3.0 was released on December 2008. It was designed to rectify fundamental design flaws in the language. The changes required break backwards compatibility with the 2.x series, which necessitated a new major version number.

Major changes

Subsequent releases in the Python 3.x series have included additional, substantial new features; all ongoing development of the language is done in the 3.x series.

Porting your code to Python 3

For a complete reference and advise, see https://docs.python.org/3/howto/pyporting.html

It is possible to write code that works for both major versions of Python, and it is the recommended strategy for maximum compatibility and flexibility. See the following page for a comprehensive list of compatible idioms. The easiest way to make sure your python 2 code can run on python 3 is to use automatic conversion tools such as futurize. Even if they are not perfect in all cases, they should take care of adapting the vast majority of your code base without too many bugs introduced. Futurize will also generate code that is compatible with both editions. See the quick start guide for instructions on how to use this tool.

Additionally, you may want to have a look at other tools and resources such as:

Python 3 at ECMWF

Both python and python3 modules can be loaded at the same time.

Python3 module IS NOT loaded by default, so do not forget to load it before running your scripts!


Newest versions of the ECMWF packages and libraries support now both python 2 and 3.

When running on an ECMWF platform, all recent installations of ECMWF software packages and libraries can now be used with python 2.7 and 3.6. In order to work with the new python 3, you should:

module load python3

You may then run your python scripts by:

python3 yourscript.py

or editing the first line of your script, if you run it as an executable:

#!/usr/bin/env python3


./yourscript.py

For sustainability and maintainability reasons, some extra modules available in Python 2 may not be installed in the Python 3. If you need a module that is missing, please consider if you can use it through a virtual environment. This is particularly recommended if the module is being evaluated or tested, or if it's not going to be used widely at the centre. If in doubt, please get in touch using the ECMWF Support Portal at https://support.ecmwf.int

You may use the Python chat room to discuss any Python matter with your fellow Python enthusiasts.