Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

error with importing sage into a python file

Im trying to import a sage package (var) in a python file

from sage.all import var

but when run the file Im getting this error :

Error
Traceback (most recent call last):

    execfile("/home/sagefolder/SageMath/myapp/core/test.sage")
  File "/home/sagefolder/SageMath/ubbr/engine/test.py", line 20, in <module>
    from sage.all import var
  File "/home/sagefolder/SageMath/local/lib/python2.7/site-packages/sage/all.py", line 71, in <module>
    from sage.env import SAGE_ROOT, SAGE_SRC, SAGE_DOC_SRC, SAGE_LOCAL, DOT_SAGE, SAGE_ENV
  File "/home/sagefolder/SageMath/local/lib/python2.7/site-packages/sage/env.py", line 123, in <module>
    _add_variable_or_fallback('SAGE_ETC',        opj('$SAGE_LOCAL', 'etc'))
  File "/home/sagefolder/SageMath/local/lib/python2.7/site-packages/sage/env.py", line 103, in _add_variable_or_fallback
    value = sep.join(components)
TypeError: sequence item 0: expected string, NoneType found

my guess was that the problem was related to the env path. but even

sys.path.append('/path/to/the/sage/')

it does not work

I would be pleased if anybody can help me as Im doing an important project and I really need to use sage.

error with importing sage into a python file

Im trying to import a sage package (var) in a python file

from sage.all import var

but when run the file Im getting this error :

Error
Traceback (most recent call last):

    execfile("/home/sagefolder/SageMath/myapp/core/test.sage")
  File "/home/sagefolder/SageMath/ubbr/engine/test.py", line 20, in <module>
    from sage.all import var
  File "/home/sagefolder/SageMath/local/lib/python2.7/site-packages/sage/all.py", line 71, in <module>
    from sage.env import SAGE_ROOT, SAGE_SRC, SAGE_DOC_SRC, SAGE_LOCAL, DOT_SAGE, SAGE_ENV
  File "/home/sagefolder/SageMath/local/lib/python2.7/site-packages/sage/env.py", line 123, in <module>
    _add_variable_or_fallback('SAGE_ETC',        opj('$SAGE_LOCAL', 'etc'))
  File "/home/sagefolder/SageMath/local/lib/python2.7/site-packages/sage/env.py", line 103, in _add_variable_or_fallback
    value = sep.join(components)
TypeError: sequence item 0: expected string, NoneType found

my guess was that the problem problems was related to the env path. but even

sys.path.append('/path/to/the/sage/')

it does not work

It seems it has problem with the value of some env variables like 'SAGE_ROOT' and ... but according to the installation manual, if I set the symbolic link

ln -s /path/to/SageMath/sage /usr/local/bin/sage

then all the required env variable are automatically handled.

I would be pleased if anybody can help me as Im doing an important project and I really need to use sage.

error with importing sage into a python file

Im trying to import a sage package (var) in a python file

from sage.all import var

but when run the file Im getting this error :

Error
Traceback (most recent call last):

    execfile("/home/sagefolder/SageMath/myapp/core/test.sage")
execfile("/home/sagefolder/SageMath/myapp/core/test.py")
  File "/home/sagefolder/SageMath/ubbr/engine/test.py", line 20, in <module>
    from sage.all import var
  File "/home/sagefolder/SageMath/local/lib/python2.7/site-packages/sage/all.py", line 71, in <module>
    from sage.env import SAGE_ROOT, SAGE_SRC, SAGE_DOC_SRC, SAGE_LOCAL, DOT_SAGE, SAGE_ENV
  File "/home/sagefolder/SageMath/local/lib/python2.7/site-packages/sage/env.py", line 123, in <module>
    _add_variable_or_fallback('SAGE_ETC',        opj('$SAGE_LOCAL', 'etc'))
  File "/home/sagefolder/SageMath/local/lib/python2.7/site-packages/sage/env.py", line 103, in _add_variable_or_fallback
    value = sep.join(components)
TypeError: sequence item 0: expected string, NoneType found

my guess was that the problems was related to the env path. but even

sys.path.append('/path/to/the/sage/')

it does not work

It seems it has problem with the value of some env variables like 'SAGE_ROOT' and ... but according to the installation manual, if I set the symbolic link

ln -s /path/to/SageMath/sage /usr/local/bin/sage

then all the required env variable are automatically handled.

this module is called from a django views.py which is also installed as a Sage package. if I run the the module using

sage test.py

everything is ok but when it is called from a django view which is also installed as sage packages I got the mentioned error

I would be pleased if anybody can help me as Im doing an important project and I really need to use sage.