Ask Your Question

Importing Sage functions into Cython?

asked 2018-05-07 06:14:53 +0100

tuna gravatar image

I am trying to define variables in Cython part of my code like this

a,b,c = var('a,b,c')

But in this line I cant import var() function from Sage

from sage.calculus.var import var

I got this error:

$ sage -python  real_sage.sage
Compiling ./real_sage.spyx...
Traceback (most recent call last):
  File "real_sage.sage", line 6, in <module>
    from real_sage import foo
  File "real_sage.pyx", line 10, in init real_sage
  File "sage/calculus/var.pyx", line 6, in init sage.calculus.var
  File "/home/tunamustafakemal/sega/SageMath/local/lib/python2.7/site-packages/sage/symbolic/", line 15, in <module>
    from sage.symbolic.function import SymbolicFunction, sfunctions_funcs, \
  File "sage/rings/integer.pxd", line 7, in init sage.symbolic.function
  File "sage/rings/rational.pxd", line 8, in init sage.rings.integer
  File "sage/rings/rational.pyx", line 89, in init sage.rings.rational
  File "sage/rings/real_mpfr.pyx", line 1, in init sage.rings.real_mpfr
  File "sage/rings/complex_number.pxd", line 6, in init sage.libs.mpmath.utils
  File "sage/rings/complex_double.pxd", line 10, in init sage.rings.complex_number
  File "sage/rings/complex_double.pyx", line 94, in init sage.rings.complex_double
ImportError: cannot import name complex_number

Thanks for any support.

edit retag flag offensive close merge delete


FrédéricC gravatar imageFrédéricC ( 2018-05-11 21:21:46 +0100 )edit

1 Answer

Sort by » oldest newest most voted

answered 2019-06-01 07:55:42 +0100

Try importing sage.all at the top of your program.

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


Asked: 2018-05-07 06:14:53 +0100

Seen: 1,474 times

Last updated: May 07 '18