Ask Your Question
0

missing key "SAGE_LOCAL" while "import sage.all"

asked 2016-09-22 11:25:01 -0600

leo krupski gravatar image

updated 2016-09-22 13:57:26 -0600

Hello I tried to do some debugging in PyDev. I haven't done any math there yet, just tried to import sage.all and failed.

Variable sage.env.SAGE_LOCAL is "/usr/lib/sagemath//local", so maybe OK, maybe not. I don't know where this double slash comes from.When I write $SAGE_LOCAL in bash, I get "/usr/lib/sagemath/local"

This is my sage.env.SAGE_ENV:

 {'SAGE_LOCAL': '/usr/lib/sagemath//local', 'SAGE_IMPORTALL': 'yes', 'SITE_PACKAGES': ['/usr/lib/sagemath/local/lib/python2.7/site-packages', '/usr/lib/sagemath/local/lib/site-python'], 'SAGE_BANNER': '', 'TRAC_SERVER_URI': 'https://trac.sagemath.org', 'SAGE_EXTCODE': '/usr/lib/sagemath//local/share/sage/ext', 'SAGE_CYTHONIZED': '/usr/lib/sagemath//src/build/cythonized', 'SAGE_DOC_SRC': '/usr/lib/sagemath//src/doc', 'SAGE_ETC': '/usr/lib/sagemath//local/etc', 'SAGE_REPO_AUTHENTICATED': 'ssh://git@trac.sagemath.org:2222/sage.git', 'SAGE_STARTUP_FILE': '/home/a/.sage/init.sage', 'SAGE_DOT_GIT': '/usr/lib/sagemath//.git', 'UNAME': 'Linux', 'SAGE_SHARE': '/usr/lib/sagemath//local/share', 'PYTHON_EGG_CACHE': '/home/a/.sage/.python-eggs', 'SAGE_SPKG_INST': '/usr/lib/sagemath//local/var/lib/sage/installed', 'SAGE_REPO_ANONYMOUS': 'git://trac.sagemath.org/sage.git', 'SAGE_DOC': '/usr/lib/sagemath//local/share/doc/sage', 'SAGE_VERSION': '7.3', 'REALM': 'sage.math.washington.edu', 'SAGE_INC': '/usr/lib/sagemath//local/include', 'SAGE_DATE': '2016-08-04', 'SAGE_SRC': '/usr/lib/sagemath//src', 'SAGE_LIB': '/usr/lib/sagemath/local/lib/python2.7/site-packages', 'SAGE_DISTFILES': '/usr/lib/sagemath//upstream', 'LOCAL_IDENTIFIER': 'a-GA-970A-DS3.7845', 'SAGE_ROOT': '/usr/lib/sagemath/', 'HOSTNAME': 'a-GA-970A-DS3', 'SAGE_URL': 'http://sage.math.washington.edu/sage/', 'DOT_SAGE': '/home/a/.sage', 'SAGE_LOGS': '/usr/lib/sagemath//logs/pkgs'}

However SAGE looks for this variable in some dictionary that looks like this (my system variables):

{'PYTHONIOENCODING': 'UTF-8', 'LIBOVERLAY_SCROLLBAR': '0', 'XDG_RUNTIME_DIR': '/run/user/1000', 'XDG_CURRENT_DESKTOP': 'KDE', 'XDG_SESSION_TYPE': 'x11', 'QT_IM_MODULE': 'compose', 'LOGNAME': 'a', 'USER': 'a', 'HOME': '/home/a', 'XDG_VTNR': '7', 'PATH': '/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/lib64/MRO-3.2.3/R-3.2.3/lib/R:/home/a/anaconda2/bin', 'PYTHONUNBUFFERED': '1', 'PAM_KWALLET_LOGIN': '/tmp/kwallet_a.socket', 'KDE_SESSION_VERSION': '5', 'KDE_FULL_SESSION': 'true', 'XDG_SESSION_DESKTOP': 'KDE''...}

Last instruction is

from . import matrix_mpolynomial_dense   in  matrix_space.py

Before:

 else:
            from sage.matrix.matrix_space import is_MatrixSpace

( in definition of class class PolynomialRing_general(sage.algebras.algebra.Algebra in polynomial_ring.py)

And it all started with

   from sage.rings.all      import *

in all.py

Full traceback looks like this (don't think it's useful):

Traceback (most recent call last):
  File "/mnt/dca8bb8a-0bad-49dc-bd48-7f32e4fb2114/Downloads/work/trial/py.py", line 7, in <module>
    import sage.all
  File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/all.py", line 103, in <module>
    from sage.rings.all      import *
  File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/rings/all.py", line 54, in <module>
    from .number_field.all import *
  File "/usr/lib/sagemath/local/lib/python2.7/site-packages/sage/rings/number_field/all.py", line 9, in <module>
    from .totallyreal import enumerate_totallyreal_fields_prim
  File "sage/rings/number_field/totallyreal_data.pxd", line 12, in init sage.rings.number_field.totallyreal (/usr/lib/sagemath//src/build/cythonized/sage/rings/number_field/totallyreal.c:11599)
  File "sage/rings/number_field/totallyreal_data.pyx", line 39, in init sage.rings.number_field.totallyreal_data (/usr/lib/sagemath//src ...
(more)
edit retag flag offensive close merge delete

Comments

Can you tell us in which context you need this? Your title has an error message in it but you don't say what gives that error, which could be really useful for helping.

kcrisman gravatar imagekcrisman ( 2016-09-22 12:19:35 -0600 )edit

Thanks for answer. I have added some information. All I tried to do was to import sage.all I have added some information. My guess is that Sage gathers my system variable but doesn't take SAGE_LOCAL (maybe because of double slash, maybe not). Nevertheless in notebook it works OK.

leo krupski gravatar imageleo krupski ( 2016-09-22 14:06:24 -0600 )edit
1

You probably need your IDE or whatever to not just import sage.all, but to set all such variables properly - typically this is done by running sage -sh which sets all env vars correctly. I'm not familiar with PyDev so I don't know what the equivalent would be there. The Sage notebook does all this on its own, of course.

kcrisman gravatar imagekcrisman ( 2016-09-23 07:18:31 -0600 )edit
1

yeah! You solved my problem. It's enough to run bash in LiClipse's folder, run "sage -sh" and from this shell run LiClipse (or Eclipse if you like). Thank you. You can add answer, if You like. I think many people can have this problem, since old tutorials say just "import sage.all".

leo krupski gravatar imageleo krupski ( 2016-09-23 07:54:54 -0600 )edit

Can you say in which tutorials? I don't use these systems myself, but we should fix them if they are live documentation.

kcrisman gravatar imagekcrisman ( 2016-09-23 09:50:20 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-09-23 09:49:50 -0600

kcrisman gravatar image

Make sure to run sage -sh from a shell first! That sets all the right environment variables. (See comments for further details about this person's use case.)

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

Stats

Asked: 2016-09-22 11:25:01 -0600

Seen: 40 times

Last updated: Sep 23 '16