Differences between revisions 30 and 31
Revision 30 as of 2020-01-14 12:35:13
Size: 1981
Editor: chapoton
Comment: drop python2 as soon as possible
Revision 31 as of 2020-04-08 20:44:50
Size: 2059
Editor: mkoeppe
Comment: 9.1 will still support python2
Deletions are marked like this. Additions are marked like this.
Line 29: Line 29:
For '''version 9.0''', if you really want so, you can still build and use !SageMath with '''Python 2''', as follows. For '''version 9.0''' and the upcoming '''version 9.1''', if you really want so, you can still build and use !SageMath with '''Python 2''', as follows.
Line 37: Line 37:
Starting from '''version 9.1''', the compatibility with Python 2 will no longer be ensured. In the development versions after version 9.1 leading to '''version 9.2''', the compatibility with Python 2 will no longer be ensured.

Summary of the Python 3 switch

SageMath has been running on top of Python 2 since the beginning, until version 8.9, released in september 2019.

Starting from version 9.0 released in January 2020, SageMath is running on top of Python 3.

The change from Python 2 to Python 3 has already been made by all major scientific software based on Python, including NumPy, SciPy and Jupyter. It becomes more and more common for scientific Python software to work only under Python 3. Moreover, the official end of life for Python 2 was the end of 2019.

Python 3 has some major backward incompatibilities with Python 2, and adapting SageMath code from Python 2 to Python 3 takes some care and some work. Some basic instructions for doing that can be found in the following wiki pages:

More complete instructions for porting code can be found in the official Python documentation.

Some more specific details follow.

Old notebooks

The "legacy notebook", which was used by SageMath for a long time, has been replaced by the Jupyter notebook since 2015. Because the legacy notebook is no longer maintained, it is not compatible with Python 3 and will not be available in versions 9.0 and higher of SageMath.

All people that still have old-style notebooks are urged to migrate them to Jupyter notebooks (using Sagemath 8.9 or previous releases), by running the command

sage -n export

Compiling with Python 2

For version 9.0 and the upcoming version 9.1, if you really want so, you can still build and use SageMath with Python 2, as follows.

make configure
./configure --with-python=2
make build

Beware that you will need to call the second line again if you ever call "make distclean".

In the development versions after version 9.1 leading to version 9.2, the compatibility with Python 2 will no longer be ensured.

Python3-Switch (last edited 2021-02-09 13:32:40 by chapoton)