Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

...

Python 3 at ECMWF

Info

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. At ECMWF, their installations are done so both python 2.7 and 3.6 can be used. In order to work with the new python 3, you should:

No Format
module load python3

You may then run your python scripts by:

No Format
python3 yourscript.py

or editing your script shebang:

Code Block
languagepy
#!/usr/bin/env python3