I am writing a module for sage, and I want to import some sage objects cleanly, without calling the heavy import sage.all
. But without it, I often get errors.
$ sage -python
Python 3.7.3 (default, May 21 2020, 07:31:27)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from sage.rings.integer import Integer
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sage/rings/rational.pxd", line 8, in init sage.rings.integer (build/cythonized/sage/rings/integer.c:53202)
File "sage/rings/rational.pyx", line 95, in init sage.rings.rational (build/cythonized/sage/rings/rational.c:39849)
File "sage/rings/real_mpfr.pyx", line 1, in init sage.rings.real_mpfr (build/cythonized/sage/rings/real_mpfr.c:44200)
File "sage/rings/complex_number.pxd", line 6, in init sage.libs.mpmath.utils (build/cythonized/sage/libs/mpmath/utils.c:8637)
File "sage/rings/complex_double.pxd", line 7, in init sage.rings.complex_number (build/cythonized/sage/rings/complex_number.c:24172)
File "sage/rings/complex_double.pyx", line 96, in init sage.rings.complex_double (build/cythonized/sage/rings/complex_double.c:24325)
ImportError: cannot import name complex_number
>>> from sage.all import *
>>> from sage.rings.integer import Integer
>>>
$ sage
┌────────────────────────────────────────────────────────────────────┐
│ SageMath version 9.1, Release Date: 2020-05-20 │
│ Using Python 3.7.3. Type "help()" for help. │
└────────────────────────────────────────────────────────────────────┘
This is just an example.