Ask Your Question
1

Running sage dependent scripts throws error

asked 2013-10-23 05:57:43 +0100

anonymous user

Anonymous

updated 2013-10-23 06:08:14 +0100

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?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2013-10-23 11:41:46 +0100

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
edit flag offensive delete link more

Comments

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

warbot gravatar imagewarbot ( 2013-10-26 12:39:44 +0100 )edit

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 ( 2013-10-26 16:05:28 +0100 )edit

They should work without the import statements too.

ppurka gravatar imageppurka ( 2013-10-26 19:52:38 +0100 )edit

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: 2013-10-23 05:57:43 +0100

Seen: 841 times

Last updated: Oct 23 '13