Ask Your Question
1

Running sage dependent scripts throws error

asked 11 years ago

anonymous user

Anonymous

updated 11 years ago

script1.sage:

#!/usr/bin/env sage
import script2

script2.sage:

#!/usr/bin/env sage
smth

After I've done:

sage script2.sage # script2.py was generated
sage script1.sage # script1.py generated that uses script2.py

Both script1 and script2 do have:

from sage.all_cmdline import *

Everything works good if I:

/usr/bin/env sage script1.sage # or
sage script1.sage

But when trying to run script1.sage in this way:

./script1.sage
# =>
# Traceback (most recent call last):
# File "./script1.sage", line 4, in <module>
#   import script2
# File "path/script2.py", line 2, in <module>
#   from sage.all_cmdline import *   # import sage library
# ImportError: No module named sage.all_cmdline

Why?

Preview: (hide)

1 Answer

Sort by » oldest newest most voted
1

answered 11 years ago

ppurka gravatar image

Works here:

/tmp/tmpf6hj9C» cat b.sage
#!/usr/bin/env sage
from sage.all_cmdline import *
xy = 2;
print xy


/tmp/tmpf6hj9C» cat a.sage
#!/usr/bin/env sage
import b
from sage.all_cmdline import *
xx = 2;
print xx, b.xy


/tmp/tmpf6hj9C» ./a.sage
2
2 2
Preview: (hide)
link

Comments

Any clues on why I'm getting this exception? Some places to look at?

warbot gravatar imagewarbot ( 11 years ago )

After adding `from sage.all_cmdline import * ` to a.sage, in my case, everything start working. Nevertheless your examples do work for me even without `from sage.all_cmdline import *`

warbot gravatar imagewarbot ( 11 years ago )

They should work without the import statements too.

ppurka gravatar imageppurka ( 11 years ago )

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: 11 years ago

Seen: 869 times

Last updated: Oct 23 '13