Ask Your Question

warbot's profile - activity

2018-10-16 07:00:25 -0600 received badge  Notable Question (source)
2017-01-19 09:47:42 -0600 received badge  Popular Question (source)
2016-12-14 16:29:33 -0600 received badge  Notable Question (source)
2016-01-01 18:35:49 -0600 received badge  Popular Question (source)
2013-11-03 01:16:12 -0600 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:
s.sage:

#!/usr/bin/env sage

a = 100020003000400050006000700080009000L

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

sage s.sage # => s.py

r.rb:

require 'rubypython'

RubyPython.start

sys = RubyPython.import("sys")
sys.path.append("/Users/name/Documents") # path to s.py 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
sys.path.append("/Applications/sage/devel/sage/build/lib.macosx-10.8-x86_64-2.7")

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/c_lib.so, 2): Library not loaded: libcsage.dylib
  Referenced from: /Applications/sage/devel/sage/build/lib.macosx-10.8-x86_64-2.7/sage/ext/c_lib.so
  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 09:11:25 -0600 received badge  Supporter (source)
2013-10-26 09:11:24 -0600 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 2
2013-10-26 09:11:23 -0600 received badge  Scholar (source)
2013-10-26 09:05:28 -0600 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 05:39:44 -0600 commented answer Running sage dependent scripts throws error

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

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

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?