Ask Your Question
1

Is it possible to update the Sage Python?

asked 2017-04-05 23:13:53 +0100

cybervigilante gravatar image

updated 2017-04-06 07:58:12 +0100

FrédéricC gravatar image

I noticed Sage can run a Python notebook, but it's 2.7 when I'm used to using 3.x. It is possible to update the Python in Sage? Also I'm on Windows so I'm using the Sage Virtualbox appliance, which might make it impossible. But is it possible in a sage native host like Linux?

edit retag flag offensive close merge delete

Comments

Not yet. Sage is on track to switch to Python 3 - see e.g. https://trac.sagemath.org/ticket/15980

kcrisman gravatar imagekcrisman ( 2017-04-06 03:04:14 +0100 )edit

A possibility would be to import "things" from the future .

python-future.org/imports.html

docs.python.org/3/library/__future__.html

...stack over post....

For instance:

sage: from __future__ import absolute_import, print_function    # , division # but this is ok in sage
sage: type(print)
<type 'builtin_function_or_method'>
sage: print 1,2,3
  File "<ipython-input-117-e0b3713317fc>", line 1
    print Integer(1),Integer(2),Integer(3)
                ^
SyntaxError: invalid syntax

sage: print( 1,2,3 )
1 2 3
dan_fulea gravatar imagedan_fulea ( 2017-04-20 22:19:31 +0100 )edit

For reference: since the 9.0 release (1 Jan 2020), SageMath is now based on Python 3.

eric_g gravatar imageeric_g ( 2020-04-14 15:08:35 +0100 )edit

1 Answer

Sort by » oldest newest most voted
4

answered 2018-10-09 16:00:19 +0100

slelievre gravatar image

updated 2019-05-28 22:14:27 +0100

(Edited 2019-05-28 after much progress was made thanks to @FrédéricC and a few other developers).

You can download the source for Sage and compile it for Python 3.

For that, change to the directory containing the sources and run

$ make configure
$ ./configure --with-python=3
$ make

Before the documentation was made to build with Python 3, it was advised to run make build instead of make, but this is now fixed.

Making all tests pass is the object of

Note that CoCalc lets you use "Sage Py3" and "Sage development Py3" in the terminal or in CoCalc's .sagews worksheets or in Jupyter.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-04-05 23:13:53 +0100

Seen: 1,685 times

Last updated: May 28 '19