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.Sun, 02 Jan 2011 10:30:30 +0100Import sage python modulehttps://ask.sagemath.org/question/7824/import-sage-python-module/Hi!
I've been trying to setup sagemath in order to use the sage python module by importing it in an other python project. I'm trying to get the same thing that i get when calling:
./sage -python
Is there a deployment script/python egg that install the module in dist-package? Is there a folder i can add to my python path?
So far I downloaded the "sage-4.6-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux.tar.lzma" version and unpacked it to "/opt/sage" while changing sure to update the "SAGE_ROOT" in /opt/sage.
I know there must be a way to do so because [FAQ](http://wiki.sagemath.org/faq#HowdoIimportSageintoaPythonscript.3F) mentions it. Python 2.6 is already bundled with my machine so i guess all I have to do is add a folder to my python path?Sun, 19 Dec 2010 13:51:53 +0100https://ask.sagemath.org/question/7824/import-sage-python-module/Answer by charettes for <p>Hi!</p>
<p>I've been trying to setup sagemath in order to use the sage python module by importing it in an other python project. I'm trying to get the same thing that i get when calling:</p>
<pre><code>./sage -python
</code></pre>
<p>Is there a deployment script/python egg that install the module in dist-package? Is there a folder i can add to my python path?</p>
<p>So far I downloaded the "sage-4.6-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux.tar.lzma" version and unpacked it to "/opt/sage" while changing sure to update the "SAGE_ROOT" in /opt/sage.</p>
<p>I know there must be a way to do so because <a href="http://wiki.sagemath.org/faq#HowdoIimportSageintoaPythonscript.3F">FAQ</a> mentions it. Python 2.6 is already bundled with my machine so i guess all I have to do is add a folder to my python path?</p>
https://ask.sagemath.org/question/7824/import-sage-python-module/?answer=11883#post-id-11883I tried "cd" to SAGE_ROOT/devel/sage did the following.
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.environ['SAGE_ROOT'] = '/opt/sage'
>>> from sage.all import *
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "sage/all.py", line 56, in <module>
from sage.rings.memory import pmem_malloc
ImportError: No module named memory
I'm stuck to this, any idea why i get this error while running sage from the console and netbook works fine?Mon, 20 Dec 2010 11:24:42 +0100https://ask.sagemath.org/question/7824/import-sage-python-module/?answer=11883#post-id-11883Answer by Felix Lawrence for <p>Hi!</p>
<p>I've been trying to setup sagemath in order to use the sage python module by importing it in an other python project. I'm trying to get the same thing that i get when calling:</p>
<pre><code>./sage -python
</code></pre>
<p>Is there a deployment script/python egg that install the module in dist-package? Is there a folder i can add to my python path?</p>
<p>So far I downloaded the "sage-4.6-linux-64bit-ubuntu_10.04.1_lts-x86_64-Linux.tar.lzma" version and unpacked it to "/opt/sage" while changing sure to update the "SAGE_ROOT" in /opt/sage.</p>
<p>I know there must be a way to do so because <a href="http://wiki.sagemath.org/faq#HowdoIimportSageintoaPythonscript.3F">FAQ</a> mentions it. Python 2.6 is already bundled with my machine so i guess all I have to do is add a folder to my python path?</p>
https://ask.sagemath.org/question/7824/import-sage-python-module/?answer=11887#post-id-11887I don't think that this is really possible at present - an mostly uninformed guess is that anything relying on an spkg or external programs would break. If you want to try it anyway, maybe set SAGE_ROOT as devel/sage/build/ (since that's the built version of the code).
There's a [thread](http://groups.google.com/group/sage-devel/browse_thread/thread/22d4b1d90a536f37/b1dfcca06620f30b) on sage-devel that might be useful.Tue, 21 Dec 2010 18:51:32 +0100https://ask.sagemath.org/question/7824/import-sage-python-module/?answer=11887#post-id-11887Comment by John Palmieri for <p>I don't think that this is really possible at present - an mostly uninformed guess is that anything relying on an spkg or external programs would break. If you want to try it anyway, maybe set SAGE_ROOT as devel/sage/build/ (since that's the built version of the code).</p>
<p>There's a <a href="http://groups.google.com/group/sage-devel/browse_thread/thread/22d4b1d90a536f37/b1dfcca06620f30b">thread</a> on sage-devel that might be useful.</p>
https://ask.sagemath.org/question/7824/import-sage-python-module/?comment=22371#post-id-22371A better location for the built version is SAGE_ROOT/local/lib/python/site-libraries/sage. Adding SAGE_ROOT/local/lib/python/site-libraries to your PYTHON_PATH helps, but doesn't fix the problem altogether.Tue, 21 Dec 2010 21:38:53 +0100https://ask.sagemath.org/question/7824/import-sage-python-module/?comment=22371#post-id-22371Comment by charettes for <p>I don't think that this is really possible at present - an mostly uninformed guess is that anything relying on an spkg or external programs would break. If you want to try it anyway, maybe set SAGE_ROOT as devel/sage/build/ (since that's the built version of the code).</p>
<p>There's a <a href="http://groups.google.com/group/sage-devel/browse_thread/thread/22d4b1d90a536f37/b1dfcca06620f30b">thread</a> on sage-devel that might be useful.</p>
https://ask.sagemath.org/question/7824/import-sage-python-module/?comment=22358#post-id-22358Thank you very much i'll have a look at this thread :)Sun, 02 Jan 2011 10:30:30 +0100https://ask.sagemath.org/question/7824/import-sage-python-module/?comment=22358#post-id-22358