Ask Your Question

Revision history [back]

You first need to import sage.all.

The following should work (I'm including version info for reference):

$ sage -v
SageMath version 8.1, Release Date: 2017-12-07
$ sage -python
Python 2.7.14 (default, Dec  9 2017, 17:25:34) 
[GCC 7.2.0] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sage.all
>>> from sage.rings.integer_ring import ZZ
>>>

You first need to import sage.all.

The following should work (I'm including version info for reference):

$ sage -v
SageMath version 8.1, Release Date: 2017-12-07
$ sage -python
Python 2.7.14 (default, Dec  9 2017, 17:25:34) 
[GCC 7.2.0] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sage.all
>>> from sage.rings.integer_ring import ZZ
>>>

Edit: you could even directly import ZZ form sage.all:

$ sage -python 
Python 2.7.14 (default, Dec  9 2017, 17:25:34) 
[GCC 7.2.0] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from sage.all import ZZ
>>>

You first need to import sage.all.

The following should work (I'm including version info for reference):

$ sage -v
SageMath version 8.1, Release Date: 2017-12-07
$ sage -python
Python 2.7.14 (default, Dec  9 2017, 17:25:34) 
[GCC 7.2.0] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import sage.all
>>> from sage.rings.integer_ring import ZZ
>>>

Edit: you could even directly import ZZ form sage.all:

$ sage -python 
Python 2.7.14 (default, Dec  9 2017, 17:25:34) 
[GCC 7.2.0] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from sage.all import ZZ
>>>

References: