Ask Your Question

warbot's profile - activity

2018-10-16 14:00:25 +0100 received badge  Notable Question (source)
2017-01-19 16:47:42 +0100 received badge  Popular Question (source)
2016-12-14 23:29:33 +0100 received badge  Notable Question (source)
2016-01-02 01:35:49 +0100 received badge  Popular Question (source)
2013-11-03 08:16:12 +0100 asked a question rubypython and sage

I would like to have a python back-end with ruby front-end. For that reason i'm using rubypython.

My question is: can I use sage with rubypython lib?

The example that did not work for me:

#!/usr/bin/env sage

a = 100020003000400050006000700080009000L

print "a = {0}".format(a)

sage s.sage # =>


require 'rubypython'


sys = RubyPython.import("sys")
sys.path.append("/Users/name/Documents") # path to folder to import it
sys.path.append("#{ENV["SAGE_ROOT"]}")   # added in hope for the best

# added path to sage, otherwise => ImportError: No module named sage.all_cmdline

RubyPython.import 's'

Running the script:

ruby r.rb # =>
RubyPython::PythonError: ImportError: dlopen(/Applications/sage/devel/sage/build/lib.macosx-10.8-x86_64-2.7/sage/ext/, 2): Library not loaded: libcsage.dylib
  Referenced from: /Applications/sage/devel/sage/build/lib.macosx-10.8-x86_64-2.7/sage/ext/
  Reason: image not found
  import at /Users/name/.rvm/gems/jruby-1.7.6/gems/rubypython-0.6.3/lib/rubypython.rb:107
  (root) at iruby.rb:18
2013-10-26 16:11:25 +0100 received badge  Supporter (source)
2013-10-26 16:11:24 +0100 marked best answer Running sage dependent scripts throws error

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
2013-10-26 16:11:23 +0100 received badge  Scholar (source)
2013-10-26 16:05:28 +0100 commented answer Running sage dependent scripts throws error

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 *`

2013-10-26 12:39:44 +0100 commented answer Running sage dependent scripts throws error

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

2013-10-23 06:03:51 +0100 received badge  Student (source)
2013-10-23 05:59:38 +0100 received badge  Editor (source)
2013-10-23 05:57:43 +0100 asked a question Running sage dependent scripts throws error


#!/usr/bin/env sage
import script2


#!/usr/bin/env sage

After I've done:

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

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:

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