Differences between revisions 1 and 35 (spanning 34 versions)
Revision 1 as of 2019-10-30 10:58:08
Size: 1413
Editor: chapoton
Comment:
Revision 35 as of 2020-06-06 16:32:24
Size: 2341
Editor: chapoton
Comment: details
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
{{https://www.python.org/static/community_logos/python-powered-w-100x40.png||width=100px}}
Line 3: Line 5:
!SageMath has been running under '''Python 2''' since the beginning, until version 8.9. !SageMath has been running on top of '''Python 2''' since the beginning, until version 8.9, released in September 2019.
Line 5: Line 7:
Starting from version 9.0 (to be released later in 2019), !SageMath will be running on top of '''Python 3'''. Starting from [[ReleaseTours/sage-9.0|Sage 9.0]], released in January 2020, !SageMath is running on top of '''Python 3'''.
Line 7: Line 9:
The change from Python2 to Python3 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 Python3. Moreover, the official end of life for Python2 is the end of 2019. 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.
Line 9: Line 11:
For all these reasons, it is necessary for Sagemath to switch to Python 3. After a lot of work and a lot of time, this is now possible and will be done in the 9.0 version. 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:
Line 11: Line 13:
This will not be without pain for the users of sage. Python 3 has some major backward incompatibilities with Python2, and adapting the code takes some care and some work.  * [[Python3-compatible code]] (for developers)
 * [[Python3-user]] (for users)
Line 13: Line 16:
Some basic instructions can be found in [[Python3-compatible??]] More complete instructions for porting code can be found in the official [[https://docs.python.org/dev/howto/pyporting.html|Python documentation]].
Line 17: Line 20:
=== Old notebooks === == Old notebooks ==
Line 19: Line 22:
The "legacy Sage notebook", which was used by Sage for a long time, has been replaced by the Jupyter notebook XXX years ago. 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. 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.
Line 21: Line 24:
All people that still have old-style notebooks are urged to migrate them to Jupyter notebooks now. 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 [[ReleaseTours/sage-9.0|SageMath 9.0]] and [[ReleaseTours/sage-9.1|SageMath 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 [[ReleaseTours/sage-9.2|SageMath 9.2]], support for Python 2 will be removed ([[https://trac.sagemath.org/ticket/29141|Meta-ticket #29141: Remove Python 2 support for Sage 9.2; upgrades enabled by the removal]])

https://www.python.org/static/community_logos/python-powered-w-100x40.png

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 Sage 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 SageMath 9.0 and SageMath 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 SageMath 9.2, support for Python 2 will be removed (Meta-ticket #29141: Remove Python 2 support for Sage 9.2; upgrades enabled by the removal)

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