Ask Your Question

Error when trying to import without sage.all

asked 2017-12-11 21:06:39 -0500

jaebond gravatar image

updated 2017-12-12 10:57:16 -0500

I am trying to import only the Sage functions needed as is done in the Sage source code, but I am running into issues. For example, (running sage -python),

>>> from import Group

results in

from sage.rings.complex_double import CDF
File "sage/rings/real_double.pxd", line 8, in init sage.rings.complex_double (/export/pkgs/linux-rh6/sagemath-7.0/src/build/cythonized/sage/rings/complex_double.c:22654)
File "sage/rings/real_double.pyx", line 64, in init sage.rings.real_double (/export/pkgs/linux-rh6/sagemath-7.0/src/build/cythonized/sage/rings/real_double.c:25060)
ImportError: cannot import name ZZ

(I can post the full traceback if that would be helpful.) Similar things happen for almost any import I try. I was using the import_statements to determine what to import.

Am I missing something?


I think I get the picture a little better now. The Sage source files aren't meant to be imported in Python, they are meant to be imported into Sage, which presumably runs import sage.all when it starts.

edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2017-12-11 21:38:30 -0500

slelievre gravatar image

updated 2017-12-11 22:15:51 -0500

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 import Group


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


Asked: 2017-12-11 21:06:39 -0500

Seen: 26 times

Last updated: Dec 12 '17