Opened 10 years ago

Last modified 7 years ago

#13083 new defect

Importing a specific module usually fails

Reported by: Jan Pöschko Owned by: Jason Grout
Priority: major Milestone: sage-6.9
Component: misc Keywords:
Cc: Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by Jeroen Demeyer)

When I run sage --python and then try to import something "specific" (e.g. from the rings module), I get the following:

$ sage --python
Python 2.7.2 (default, May 16 2012, 20:18:27) 
[GCC 4.6.3] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from sage.rings.all import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Applications/sage/local/lib/python2.7/site-packages/sage/rings/all.py", line 42, in <module>
    from ideal import Ideal, is_Ideal
  File "/Applications/sage/local/lib/python2.7/site-packages/sage/rings/ideal.py", line 35, in <module>
    from sage.interfaces.singular import singular as singular_default
  File "/Applications/sage/local/lib/python2.7/site-packages/sage/interfaces/singular.py", line 340, in <module>
    import sage.rings.integer
  File "integer.pyx", line 170, in init sage.rings.integer (sage/rings/integer.c:35815)
  File "/Applications/sage/local/lib/python2.7/site-packages/sage/rings/infinity.py", line 200, in <module>
    import sage.rings.rational
  File "fast_arith.pxd", line 5, in init sage.rings.rational (sage/rings/rational.c:25959)
  File "fast_arith.pyx", line 51, in init sage.rings.fast_arith (sage/rings/fast_arith.c:7723)
  File "integer_ring.pyx", line 69, in init sage.rings.integer_ring (sage/rings/integer_ring.c:11304)
  File "/Applications/sage/local/lib/python2.7/site-packages/sage/structure/factorization.py", line 188, in <module>
    from sage.misc.all import prod
  File "/Applications/sage/local/lib/python2.7/site-packages/sage/misc/all.py", line 81, in <module>
    from functional import (additive_order,
  File "/Applications/sage/local/lib/python2.7/site-packages/sage/misc/functional.py", line 36, in <module>
    from sage.rings.complex_double import CDF
  File "complex_double.pyx", line 88, in init sage.rings.complex_double (sage/rings/complex_double.c:15160)
  File "real_mpfr.pxd", line 15, in init sage.rings.complex_number (sage/rings/complex_number.c:16587)
  File "real_mpfr.pyx", line 1, in init sage.rings.real_mpfr (sage/rings/real_mpfr.c:30314)
  File "utils.pyx", line 11, in init sage.libs.mpmath.utils (sage/libs/mpmath/utils.c:6099)
  File "/Applications/sage/local/lib/python2.7/site-packages/sage/all.py", line 72, in <module>
    from sage.libs.all       import *
  File "/Applications/sage/local/lib/python2.7/site-packages/sage/libs/all.py", line 1, in <module>
    import sage.libs.ntl.all  as ntl
  File "/Applications/sage/local/lib/python2.7/site-packages/sage/libs/ntl/__init__.py", line 1, in <module>
    import all
  File "/Applications/sage/local/lib/python2.7/site-packages/sage/libs/ntl/all.py", line 26, in <module>
    from sage.libs.ntl.ntl_ZZ import (
  File "ntl_ZZ.pyx", line 28, in init sage.libs.ntl.ntl_ZZ (sage/libs/ntl/ntl_ZZ.cpp:6393)
  File "integer_ring.pyx", line 1062, in sage.rings.integer_ring.IntegerRing (sage/rings/integer_ring.c:9840)
NameError: ZZ

This also happens for other modules, e.g. from sage.modules.all import *. However, it does not occur when I do

from sage.all import *

first.

Change History (3)

comment:1 Changed 10 years ago by Mike Hansen

Before you can do any of those specific imports, you need to do

import sage.all

which will import things in the correct order and make sure everything is initialized. After that, you can import what you need.

comment:2 in reply to:  1 Changed 10 years ago by Florent Hivert

Replying to mhansen:

Before you can do any of those specific imports, you need to do

import sage.all

which will import things in the correct order and make sure everything is initialized. After that, you can import what you need.

I think this nevertheless witnesses some problems with Sage's imports and modularity. Is there a good reason why this shouldn't work ?

Florent

comment:3 Changed 7 years ago by Jeroen Demeyer

Component: buildmisc
Description: modified (diff)
Milestone: sage-6.9
Owner: changed from Georg S. Weber to Jason Grout
Summary: Import fails in sage-pythonImporting a specific module usually fails
Note: See TracTickets for help on using tickets.