# 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 `import`

ed correctly?

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

Are you storing the source in an executable file, say `a.sage`, and then running that executable file? That won't work since env will try to run the command `sage -python` instead of running `sage` with the argument `-python`. Otherwise, the above works just fine here. I saved it as `a.sage` and ran `sage a.sage`.

@ppurka If I heard your question right: I don't run `/path/to.sage` using `./to.sage` - I tried to run the script using the commands described in the section "My Situation".

@ppurka I added some information concerning my working environment to my question. I hope this helps to solve my question.

Why do you have all these environment variables? I have none, and I have no problems in executing .sage, .py, .spyx, etc files by invoking them as you have written in the section "My Situation". Here is the output from my env: ~» env | grep -i sage ~ [1] »