ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 14 Apr 2020 15:08:35 +0200Is it possible to update the Sage Python?https://ask.sagemath.org/question/37181/is-it-possible-to-update-the-sage-python/ 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?Wed, 05 Apr 2017 23:13:53 +0200https://ask.sagemath.org/question/37181/is-it-possible-to-update-the-sage-python/Comment by kcrisman for <p>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?</p>
https://ask.sagemath.org/question/37181/is-it-possible-to-update-the-sage-python/?comment=37183#post-id-37183Not yet. Sage is on track to switch to Python 3 - see e.g. https://trac.sagemath.org/ticket/15980Thu, 06 Apr 2017 03:04:14 +0200https://ask.sagemath.org/question/37181/is-it-possible-to-update-the-sage-python/?comment=37183#post-id-37183Comment by dan_fulea for <p>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?</p>
https://ask.sagemath.org/question/37181/is-it-possible-to-update-the-sage-python/?comment=37354#post-id-37354A possibility would be to import "things" from the *future* .
[python-future.org/imports.html](http://python-future.org/imports.html)
[docs.python.org/3/library/__future__.html](https://docs.python.org/3/library/__future__.html)
[...stack over post.... ](http://stackoverflow.com/questions/7075082/what-is-future-in-python-used-for-and-how-when-to-use-it-and-how-it-works)
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 3Thu, 20 Apr 2017 22:19:31 +0200https://ask.sagemath.org/question/37181/is-it-possible-to-update-the-sage-python/?comment=37354#post-id-37354Comment by eric_g for <p>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?</p>
https://ask.sagemath.org/question/37181/is-it-possible-to-update-the-sage-python/?comment=50757#post-id-50757For reference: since the 9.0 release (1 Jan 2020), SageMath is now based on Python 3.Tue, 14 Apr 2020 15:08:35 +0200https://ask.sagemath.org/question/37181/is-it-possible-to-update-the-sage-python/?comment=50757#post-id-50757Answer by slelievre for <p>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?</p>
https://ask.sagemath.org/question/37181/is-it-possible-to-update-the-sage-python/?answer=43884#post-id-43884(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
- [Sage Trac ticket 26212: py3: make all tests pass](https://trac.sagemath.org/ticket/26212)
Note that CoCalc lets you use "Sage Py3" and "Sage development Py3"
in the terminal or in CoCalc's .sagews worksheets or in Jupyter.Tue, 09 Oct 2018 16:00:19 +0200https://ask.sagemath.org/question/37181/is-it-possible-to-update-the-sage-python/?answer=43884#post-id-43884