Ask Your Question
0

Import problem

asked 2012-02-02 23:04:49 +0100

araichev gravatar image

Hi all:

I'm editing sage.categories.quotient_fields and trying to import the algebraic_dependence() function. When i do so by inserting

from sage.rings.polynomial.multi_polynomial_sequence import algebraic_dependence

at the top of the file, saving, and rebuilding Sage, i get the following error when starting Sage. Is it some kind of circular importing problem?

AttributeError                            Traceback (most recent call last)

/Applications/sage/local/lib/python2.6/site-packages/IPython/ipmaker.pyc in     force_import(modname, force_reload)
 61         reload(sys.modules[modname])
 62     else:
---> 63         __import__(modname)
 64         
 65 

/Applications/sage/local/bin/ipy_profile_sage.py in <module>()
  5     preparser(True)
  6     
----> 7     import sage.all_cmdline
  8     sage.all_cmdline._init_cmdline(globals())
  9     

/Applications/sage/local/lib/python2.6/site-packages/sage/all_cmdline.py in <module>()
 12 try:
 13 
---> 14     from sage.all import *
 15     from sage.calculus.predefined import x
 16     preparser(on=True)

/Applications/sage/local/lib/python2.6/site-packages/sage/all.py in <module>()
 66 from time                import sleep
 67 
---> 68 from sage.misc.all       import *         # takes a while
 69 
 70 from sage.misc.sh import sh

/Applications/sage/local/lib/python2.6/site-packages/sage/misc/all.py in <module>()
 79 from func_persist import func_persist
 80 
---> 81 from functional import (additive_order,
 82                         sqrt as numerical_sqrt,
 83                         arg,

/Applications/sage/local/lib/python2.6/site-packages/sage/misc/functional.py in <module>()
 34 
 35 
---> 36 from sage.rings.complex_double import CDF
 37 from sage.rings.real_double import RDF, RealDoubleElement
 38 

/Applications/sage/local/bin/integer.pxd in init sage.rings.complex_double (sage/rings/complex_double.c:15016)()
  7 
  8 
----> 9 
 10 
 11 

/Applications/sage/local/bin/integer.pyx in init sage.rings.integer (sage/rings/integer.c:35507)()
169 
170 
--> 171 
172 
173 

/Applications/sage/local/lib/python2.6/site-packages/sage/rings/infinity.py in <module>()
198 #import sage.rings.real_mpfr
199 import sage.rings.integer
--> 200 import sage.rings.rational
201 
202 from sage.rings.integer_ring import ZZ

/Applications/sage/local/bin/fast_arith.pxd in init sage.rings.rational (sage/rings/rational.c:25818)()
  1 
  2 
----> 3 
  4 
  5 

/Applications/sage/local/bin/fast_arith.pyx in init sage.rings.fast_arith (sage/rings/fast_arith.c:7675)()
 49 
 50 
---> 51 
 52 
 53 

/Applications/sage/local/bin/integer_ring.pyx in init sage.rings.integer_ring (sage/rings/integer_ring.c:11235)()
 65 
 66 
---> 67 
 68 
 69 

/Applications/sage/local/lib/python2.6/site-packages/sage/rings/rational_field.py in <module>()
914         
915 
--> 916 QQ = RationalField()
917 Q = QQ
918 

/Applications/sage/local/lib/python2.6/site-packages/sage/rings/rational_field.py in __init__(self)
210             ('x',)
211         """
--> 212         from sage.categories.basic import QuotientFields
213         ParentWithGens.__init__(self, self, category = QuotientFields())
214         self._assign_names(('x',),normalize=False) # ???

/Applications/sage/local/lib/python2.6/site-packages/sage/categories/basic.py in <module>()
 46 
 47 from fields import Fields
---> 48 from quotient_fields import QuotientFields
 49 from finite_fields import FiniteFields
 50 

/Applications/sage/local/lib/python2.6/site-packages/sage/categories/quotient_fields.py in <module>()
 13 from sage.misc.abstract_method import abstract_method
 14 from sage.misc.misc_c import prod
---> 15 from sage.rings.polynomial.multi_polynomial_sequence import algebraic_dependence ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2012-02-03 00:59:54 +0100

It might be a circular dependency. Instead of importing at the top of the file, try importing within the class or method or function where you actually use it; that might help. That is, instead of

from sage.rings.polynomial.multi_polynomial_sequence import algebraic_dependence
def f(x,y):
    ...

try

def f(x,y):
    from sage.rings.polynomial.multi_polynomial_sequence import algebraic_dependence
    ...
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: 2012-02-02 23:04:49 +0100

Seen: 507 times

Last updated: Feb 03 '12