Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Internal Python: `No module named all`

Please Note

This is not a duplicate because the other people who've got that error message all were using an external python installation instead of sage -python /path/to.py

My Situation

I'm not able to execute scripts the following ways:

  • sage /path/to.sage (preprocessed)
  • sage /path/to.spyx
  • sage /path/to.py
  • sage -python /path/to.py

But I'm able to run correctly without problems:

  • sage $ load 'file'

The Traceback

When cython compiles an .spyx file:

Traceback (most recent call last):
  [...]
  File "_home_user_Dokumente_oak_code_sage_spyx_0.pyx", line 14, in init _home_user_Dokumente_oak_code_sage_spyx_0 (_home_user_Dokumente_oak_code_sage_spyx_0.c:754)
    sg.var('a b c')
AttributeError: 'module' object has no attribute 'var'

The statement that there's no var in the loaded module seems to be true because dir(sg) wasn't able to find anything else than __doc__ and other "underscored items".

When python tries to execute file (normal handwritten .py or a sage preprocessed .sage):

Traceback (most recent call last):
  File "sage2.py", line 2, in <module>
    from sage.all_cmdline import *   # import sage library
  File "/home/user/Dokumente/oak/code/sage.py", line 4, in <module>
    import sage.all as sg
ImportError: No module named all

The Source

#!/usr/bin/env sage -python                                                                                                                                                                                       

import sys                                                                                                                                                                                                          
import sage.all as sg                                                                                                                                                                                               

print '== TESTOUTPUT =='                                                                                                                                                                                                                                                                                                                                                                                                          
sg.var('a b c')

The Question

How can I get sage -python (sage's internal python) to execute the files specified as command line argument correctly? How can I get sage.all's members to get imported correctly?

Thanks - if anything's unclear concerning my question, please leave a comment.

click to hide/show revision 2
Adding Environment Specification

Internal Python: `No module named all`

Please Note

This is not a duplicate because the other people who've got that error message all were using an external python installation instead of sage -python /path/to.py

My Situation

I'm not able to execute scripts the following ways:

  • sage /path/to.sage (preprocessed)
  • sage /path/to.spyx
  • sage /path/to.py
  • sage -python /path/to.py

But I'm able to run correctly without problems:

  • sage $ load 'file'

The Traceback

When cython compiles an .spyx file:

Traceback (most recent call last):
  [...]
  File "_home_user_Dokumente_oak_code_sage_spyx_0.pyx", line 14, in init _home_user_Dokumente_oak_code_sage_spyx_0 (_home_user_Dokumente_oak_code_sage_spyx_0.c:754)
    sg.var('a b c')
AttributeError: 'module' object has no attribute 'var'

The statement that there's no var in the loaded module seems to be true because dir(sg) wasn't able to find anything else than __doc__ and other "underscored items".

When python tries to execute file (normal handwritten .py or a sage preprocessed .sage):

Traceback (most recent call last):
  File "sage2.py", line 2, in <module>
    from sage.all_cmdline import *   # import sage library
  File "/home/user/Dokumente/oak/code/sage.py", line 4, in <module>
    import sage.all as sg
ImportError: No module named all

The Source

#!/usr/bin/env sage -python                                                                                                                                                                                       

import sys                                                                                                                                                                                                          
import sage.all as sg                                                                                                                                                                                               

print '== TESTOUTPUT =='                                                                                                                                                                                                                                                                                                                                                                                                          
sg.var('a b c')

The Environment

My system setup:

Ubuntu 12.4 LTS
743,6 MiB64
AMD Athlon(tm) II X4 620 Processor
64 Bit

My environment variables:

[...]
declare -x LD_LIBRARY_PATH="/opt/sage/local/lib"
declare -x LESSCLOSE="/usr/bin/lesspipe %s %s"
declare -x LESSOPEN="| /usr/bin/lesspipe %s"
declare -x LIBRARY_PATH="/opt/sage/local/lib/"
[...]
declare -x PATH="/opt/sage:/opt/sage/local/bin:/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
declare -x PWD="/home/jk/Dokumente/oak/code"
declare -x PYTHONHOME="/opt/sage/local"
declare -x PYTHONPATH="/opt/sage/local/lib/python"
declare -x RANLIB="ranlib"
declare -x RHOME="/opt/sage/local/lib/R"
declare -x RM="rm"
declare -x SAGE64="no"
declare -x SAGE_DATA="/opt/sage/data"
declare -x SAGE_DOC="/opt/sage/devel/sage/doc"
declare -x SAGE_EXTCODE="/opt/sage/spkg/installed/extcode-5.7"
declare -x SAGE_LOCAL="/opt/sage/local"
declare -x SAGE_ORIG_LD_LIBRARY_PATH="/opt/sage//local/lib"
declare -x SAGE_ORIG_LD_LIBRARY_PATH_SET="True"
declare -x SAGE_PACKAGES="/opt/sage/spkg"
declare -x SAGE_ROOT="/opt/sage"
declare -x SAGE_SERVER="http://www.sagemath.org/"
declare -x SAGE_SHARE="/opt/sage/local/share"
declare -x SAGE_STARTUP_FILE="/home/user/.sage//init.sage"
declare -x SAGE_TESTDIR="/home/user/.sage//tmp"
[...]
declare -x __sage__=""

The Question

How can I get sage -python (sage's internal python) to execute the files specified as command line argument correctly? How can I get sage.all's members to get imported correctly?

Thanks - if anything's unclear concerning my question, please leave a comment.