Ask Your Question

hellman's profile - activity

2023-03-22 13:15:00 +0200 received badge  Famous Question (source)
2022-06-18 02:47:12 +0200 received badge  Notable Question (source)
2022-06-18 02:47:12 +0200 received badge  Popular Question (source)
2020-10-11 16:36:16 +0200 received badge  Supporter (source)
2020-09-18 02:12:48 +0200 received badge  Nice Question (source)
2020-09-17 10:41:30 +0200 received badge  Student (source)
2020-09-17 10:13:29 +0200 asked a question How to correctly import sage modules from python mode

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.