Ask Your Question

from sage.numerical import optimize, fail

asked 2012-05-08 18:40:57 -0500

araichev gravatar image

updated 2015-01-13 14:31:47 -0500

FrédéricC gravatar image

Hi all, what did i do wrong?

> sage -version
Sage Version 4.8, Release Date: 2012-01-20
> sage -python
Python 2.6.4 (r264:75706, Jan 20 2012, 01:12:14) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from sage.numerical import optimize
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Applications/sage/local/lib/python2.6/site-packages/sage/numerical/", line 1, in <module>
import all
File "/Applications/sage/local/lib/python2.6/site-packages/sage/numerical/", line 1, in <module>
from optimize import (find_root, find_maximum_on_interval,
File "/Applications/sage/local/lib/python2.6/site-packages/sage/numerical/", line 13, in <module>
from sage.modules.free_module_element import vector
File "integer.pxd", line 9, in init sage.modules.free_module_element (sage/modules/free_module_element.c:27684)
File "integer.pyx", line 171, in init sage.rings.integer (sage/rings/integer.c:35507)
File "/Applications/sage/local/lib/python2.6/site-packages/sage/rings/", line 200, in <module>
import sage.rings.rational
File "fast_arith.pxd", line 3, in init sage.rings.rational (sage/rings/rational.c:25818)
File "fast_arith.pyx", line 51, in init sage.rings.fast_arith (sage/rings/fast_arith.c:7675)
File "integer_ring.pyx", line 69, in init sage.rings.integer_ring (sage/rings/integer_ring.c:11264)
File "/Applications/sage/local/lib/python2.6/site-packages/sage/structure/", line 188, in <module>
from sage.misc.all import prod
File "/Applications/sage/local/lib/python2.6/site-packages/sage/misc/", line 81, in <module>
from functional import (additive_order,
File "/Applications/sage/local/lib/python2.6/site-packages/sage/misc/", 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:15116)
File "real_mpfr.pxd", line 15, in init sage.rings.complex_number (sage/rings/complex_number.c:16522)
File "real_mpfr.pyx", line 1, in init sage.rings.real_mpfr (sage/rings/real_mpfr.c:30362)
File "utils.pyx", line 11, in init sage.libs.mpmath.utils (sage/libs/mpmath/utils.c:6059)
File "/Applications/sage/local/lib/python2.6/site-packages/sage/", line 72, in <module>
from sage.libs.all       import *
File "/Applications/sage/local/lib/python2.6/site-packages/sage/libs/", line 1, in <module>
import sage.libs.ntl.all  as ntl
File "/Applications/sage/local/lib/python2.6/site-packages/sage/libs/ntl/", line 1, in <module>
import all
File "/Applications/sage/local/lib/python2.6/site-packages/sage/libs/ntl/", 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:6353)
File "integer_ring.pyx", line 1063, in sage.rings.integer_ring.IntegerRing (sage/rings/integer_ring.c:9806)
NameError: ZZ
edit retag flag offensive close merge delete

1 answer

Sort by » oldest newest most voted

answered 2012-05-08 20:47:09 -0500

Jason Grout gravatar image

You tried to import just part of Sage. You need to import everything:

from sage.all import *


import sage.all
edit flag offensive delete link more


Oh, OK. I thought i could import only the Sage module M that i wanted for a Python session and that M would automatically import its dependent modules. So, that isn't the case? I need to load all of Sage?

araichev gravatar imagearaichev ( 2012-05-10 12:18:18 -0500 )edit

There are a myriad of dependencies between all the Sage modules. You need to import all of them by importing sage.all; that will import them in the correct order.

Jason Grout gravatar imageJason Grout ( 2012-05-24 04:59:08 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2012-05-08 18:40:57 -0500

Seen: 179 times

Last updated: May 08 '12