ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 15 Nov 2011 11:40:36 +0100from sage.all import * results in libcsage.so "cannot open shared object file" errorhttps://ask.sagemath.org/question/8465/from-sageall-import-results-in-libcsageso-cannot-open-shared-object-file-error/I am having a problem importing sage modules into an instance of python 2.7. I succesfully untared the release binary tarball for 64-bit Ubuntu 10.04 ( http://boxen.math.washington.edu/sage/linux/64bit/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux.tar.lzma ) into `~/sage`. I can succesfully run sage with `./sage`.
After opening the python console (`python`), I set the relevant environmental variables and system path:
import sys
import os
os.environ['LD_LIBRARY_PATH'] = '/home/jthetzel/sage/local/lib'
os.environ['SAGE_ROOT'] = '/home/jthetzel/sage'
sys.path.append("/home/jthetzel/sage/local/lib/python/site-packages")
However, the following:
from sage.all import *
Results in:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jthetzel/sage/local/lib/python/site-packages/sage/all.py", line 63, in <module>
from sage.ext.c_lib import _init_csage, sig_on_count
ImportError: libcsage.so: cannot open shared object file: No such file or directory
The same occurs when I try different system paths, such as `/home/jthetzel/sage/local/lib` or `/home/jthetzel/sage` .
Trying `locate libcsage.so` finds:
/home/jthetzel/sage/devel/sage-main/c_lib/libcsage.so
/home/jthetzel/sage/local/lib/libcsage.so
I have read elsewhere that `./sage -b` might fix this error, but it does not in my case.
Could anyone help shed light on why `libcsage.so` can not be found? I am trying to import the sage modules into my usual python as opposed to Sage's python (`./sage -python`) because I am eventually trying to access Sage through R's Jython interface, rJython. I appreciate any guidance.Thu, 10 Nov 2011 18:58:33 +0100https://ask.sagemath.org/question/8465/from-sageall-import-results-in-libcsageso-cannot-open-shared-object-file-error/Comment by John Palmieri for <p>I am having a problem importing sage modules into an instance of python 2.7. I succesfully untared the release binary tarball for 64-bit Ubuntu 10.04 ( <a href="http://boxen.math.washington.edu/sage/linux/64bit/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux.tar.lzma">http://boxen.math.washington.edu/sage...</a> ) into <code>~/sage</code>. I can succesfully run sage with <code>./sage</code>. </p>
<p>After opening the python console (<code>python</code>), I set the relevant environmental variables and system path:</p>
<pre><code>import sys
import os
os.environ['LD_LIBRARY_PATH'] = '/home/jthetzel/sage/local/lib'
os.environ['SAGE_ROOT'] = '/home/jthetzel/sage'
sys.path.append("/home/jthetzel/sage/local/lib/python/site-packages")
</code></pre>
<p>However, the following:</p>
<pre><code>from sage.all import *
</code></pre>
<p>Results in:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jthetzel/sage/local/lib/python/site-packages/sage/all.py", line 63, in <module>
from sage.ext.c_lib import _init_csage, sig_on_count
ImportError: libcsage.so: cannot open shared object file: No such file or directory
</code></pre>
<p>The same occurs when I try different system paths, such as <code>/home/jthetzel/sage/local/lib</code> or <code>/home/jthetzel/sage</code> .</p>
<p>Trying <code>locate libcsage.so</code> finds:</p>
<pre><code>/home/jthetzel/sage/devel/sage-main/c_lib/libcsage.so
/home/jthetzel/sage/local/lib/libcsage.so
</code></pre>
<p>I have read elsewhere that <code>./sage -b</code> might fix this error, but it does not in my case.</p>
<p>Could anyone help shed light on why <code>libcsage.so</code> can not be found? I am trying to import the sage modules into my usual python as opposed to Sage's python (<code>./sage -python</code>) because I am eventually trying to access Sage through R's Jython interface, rJython. I appreciate any guidance.</p>
https://ask.sagemath.org/question/8465/from-sageall-import-results-in-libcsageso-cannot-open-shared-object-file-error/?comment=20921#post-id-20921Rather than trying to set the environment variables by hand, try running "sage -sh". Then open python and see if you can do "from sage.all import *". ("sage -sh" opens up a "Sage shell" in which all relevant environment variables have been set, hopefully correctly.) If this works, you can look at the settings for the environment variables in the script SAGE_ROOT/local/bin/sage-env. (It is also possible that Sage's python has been modified and what you're trying won't work with the system python.)Fri, 11 Nov 2011 10:37:49 +0100https://ask.sagemath.org/question/8465/from-sageall-import-results-in-libcsageso-cannot-open-shared-object-file-error/?comment=20921#post-id-20921Comment by jthetzel for <p>I am having a problem importing sage modules into an instance of python 2.7. I succesfully untared the release binary tarball for 64-bit Ubuntu 10.04 ( <a href="http://boxen.math.washington.edu/sage/linux/64bit/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux.tar.lzma">http://boxen.math.washington.edu/sage...</a> ) into <code>~/sage</code>. I can succesfully run sage with <code>./sage</code>. </p>
<p>After opening the python console (<code>python</code>), I set the relevant environmental variables and system path:</p>
<pre><code>import sys
import os
os.environ['LD_LIBRARY_PATH'] = '/home/jthetzel/sage/local/lib'
os.environ['SAGE_ROOT'] = '/home/jthetzel/sage'
sys.path.append("/home/jthetzel/sage/local/lib/python/site-packages")
</code></pre>
<p>However, the following:</p>
<pre><code>from sage.all import *
</code></pre>
<p>Results in:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jthetzel/sage/local/lib/python/site-packages/sage/all.py", line 63, in <module>
from sage.ext.c_lib import _init_csage, sig_on_count
ImportError: libcsage.so: cannot open shared object file: No such file or directory
</code></pre>
<p>The same occurs when I try different system paths, such as <code>/home/jthetzel/sage/local/lib</code> or <code>/home/jthetzel/sage</code> .</p>
<p>Trying <code>locate libcsage.so</code> finds:</p>
<pre><code>/home/jthetzel/sage/devel/sage-main/c_lib/libcsage.so
/home/jthetzel/sage/local/lib/libcsage.so
</code></pre>
<p>I have read elsewhere that <code>./sage -b</code> might fix this error, but it does not in my case.</p>
<p>Could anyone help shed light on why <code>libcsage.so</code> can not be found? I am trying to import the sage modules into my usual python as opposed to Sage's python (<code>./sage -python</code>) because I am eventually trying to access Sage through R's Jython interface, rJython. I appreciate any guidance.</p>
https://ask.sagemath.org/question/8465/from-sageall-import-results-in-libcsageso-cannot-open-shared-object-file-error/?comment=20900#post-id-20900@John Palmieri: Thanks, this was a very helpful suggestion.Tue, 15 Nov 2011 11:13:13 +0100https://ask.sagemath.org/question/8465/from-sageall-import-results-in-libcsageso-cannot-open-shared-object-file-error/?comment=20900#post-id-20900Answer by William Stein for <p>I am having a problem importing sage modules into an instance of python 2.7. I succesfully untared the release binary tarball for 64-bit Ubuntu 10.04 ( <a href="http://boxen.math.washington.edu/sage/linux/64bit/sage-4.7.2-linux-64bit-ubuntu_10.04.3_lts-x86_64-Linux.tar.lzma">http://boxen.math.washington.edu/sage...</a> ) into <code>~/sage</code>. I can succesfully run sage with <code>./sage</code>. </p>
<p>After opening the python console (<code>python</code>), I set the relevant environmental variables and system path:</p>
<pre><code>import sys
import os
os.environ['LD_LIBRARY_PATH'] = '/home/jthetzel/sage/local/lib'
os.environ['SAGE_ROOT'] = '/home/jthetzel/sage'
sys.path.append("/home/jthetzel/sage/local/lib/python/site-packages")
</code></pre>
<p>However, the following:</p>
<pre><code>from sage.all import *
</code></pre>
<p>Results in:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/jthetzel/sage/local/lib/python/site-packages/sage/all.py", line 63, in <module>
from sage.ext.c_lib import _init_csage, sig_on_count
ImportError: libcsage.so: cannot open shared object file: No such file or directory
</code></pre>
<p>The same occurs when I try different system paths, such as <code>/home/jthetzel/sage/local/lib</code> or <code>/home/jthetzel/sage</code> .</p>
<p>Trying <code>locate libcsage.so</code> finds:</p>
<pre><code>/home/jthetzel/sage/devel/sage-main/c_lib/libcsage.so
/home/jthetzel/sage/local/lib/libcsage.so
</code></pre>
<p>I have read elsewhere that <code>./sage -b</code> might fix this error, but it does not in my case.</p>
<p>Could anyone help shed light on why <code>libcsage.so</code> can not be found? I am trying to import the sage modules into my usual python as opposed to Sage's python (<code>./sage -python</code>) because I am eventually trying to access Sage through R's Jython interface, rJython. I appreciate any guidance.</p>
https://ask.sagemath.org/question/8465/from-sageall-import-results-in-libcsageso-cannot-open-shared-object-file-error/?answer=12884#post-id-12884What you're trying to do is in no way supported and should not work. You can't import Sage into any "random python" on your system, even with the PATHs setup. For starters the version of Python differs from the one where Sage was built, which should cause trouble. But that is just the beginning. You can do this (use the Sage Python):
deep:sage wstein$ ./sage -python
Python 2.6.4 (r264:75706, Nov 10 2011, 11:56:29)
>>> from sage.all import *
>>>
Also, Sage is likely to rely on modules not installed in your other Python. If there is any chance of what you're doing working by accident (and don't expect Sage to actually work well), this would be more likely to work:
$ sage -sh
$ /usr/bin/python
>>> import sys
>>> sys.path.append("/Users/wstein/Desktop/sage/local/lib/python/site-packages")
>>> import sage.all
...
ImportError: No module named _socket
If you have libraries in one copy of Python that you want to use with Sage, something you can try that might work is to start Sage's python and append to its sys.path the path of the other Python. I.e., do the exact opposite of what you're trying above. Sat, 12 Nov 2011 10:42:40 +0100https://ask.sagemath.org/question/8465/from-sageall-import-results-in-libcsageso-cannot-open-shared-object-file-error/?answer=12884#post-id-12884Comment by jthetzel for <p>What you're trying to do is in no way supported and should not work. You can't import Sage into any "random python" on your system, even with the PATHs setup. For starters the version of Python differs from the one where Sage was built, which should cause trouble. But that is just the beginning. You can do this (use the Sage Python):</p>
<pre><code>deep:sage wstein$ ./sage -python
Python 2.6.4 (r264:75706, Nov 10 2011, 11:56:29)
>>> from sage.all import *
>>>
</code></pre>
<p>Also, Sage is likely to rely on modules not installed in your other Python. If there is any chance of what you're doing working by accident (and don't expect Sage to actually work well), this would be more likely to work:</p>
<pre><code>$ sage -sh
$ /usr/bin/python
>>> import sys
>>> sys.path.append("/Users/wstein/Desktop/sage/local/lib/python/site-packages")
>>> import sage.all
...
ImportError: No module named _socket
</code></pre>
<p>If you have libraries in one copy of Python that you want to use with Sage, something you can try that might work is to start Sage's python and append to its sys.path the path of the other Python. I.e., do the exact opposite of what you're trying above. </p>
https://ask.sagemath.org/question/8465/from-sageall-import-results-in-libcsageso-cannot-open-shared-object-file-error/?comment=20898#post-id-20898@William Stein: Thanks for the clear explanation. My motive was to find a quick and easy way to call Sage from within R (I understand the other way round works fine) by importing the Sage modules into Jython, which I could then interface using the rJython package. Quick and easy seems not the solution this time.Tue, 15 Nov 2011 11:40:36 +0100https://ask.sagemath.org/question/8465/from-sageall-import-results-in-libcsageso-cannot-open-shared-object-file-error/?comment=20898#post-id-20898