Ask Your Question
1

Error when trying to import without sage.all

asked 2017-12-12 04:06:39 +0100

jaebond gravatar image

updated 2017-12-12 17:57:16 +0100

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 sage.groups.group 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?

EDIT:

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
2

answered 2017-12-12 04:38:30 +0100

slelievre gravatar image

updated 2017-12-12 05:15:51 +0100

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.groups.group import Group
>>>

References:

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-12-12 04:06:39 +0100

Seen: 711 times

Last updated: Dec 12 '17