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, 22 Aug 2017 15:54:06 +0200How to use libraries installed in for Python in Sage?https://ask.sagemath.org/question/32321/how-to-use-libraries-installed-in-for-python-in-sage/ I've installed some libraries to the 'normal' or 'system' Python on my computer.
However, Sage cannot see them.
How can I get Sage to use the libraries installed for Python? I'd prefer not to double install for Python and Sage separately.
---
I've noticed that Sage uses some Python from the Sage package. Which is clearly different than the one I'm using as "system Python". Is there a way to make these the same?Sat, 23 Jan 2016 18:08:10 +0100https://ask.sagemath.org/question/32321/how-to-use-libraries-installed-in-for-python-in-sage/Answer by tmonteil for <p>I've installed some libraries to the 'normal' or 'system' Python on my computer.</p>
<p>However, Sage cannot see them.</p>
<p>How can I get Sage to use the libraries installed for Python? I'd prefer not to double install for Python and Sage separately.</p>
<hr/>
<p>I've noticed that Sage uses some Python from the Sage package. Which is clearly different than the one I'm using as "system Python". Is there a way to make these the same?</p>
https://ask.sagemath.org/question/32321/how-to-use-libraries-installed-in-for-python-in-sage/?answer=32323#post-id-32323Indeed Sage has its own virtual environment, so it does not share Python libs with the system. Some Linux distributions try to so this but it requires quite some work.
If you want to experiment, you can try to symlink `$SAGE_ROOT/local/lib/python22.7/site-packages/some_lib` to the one of your system, but it does not awlays work. You can aslo add your system's Python lib directory to the Python path of Sage.
That said,i am not sure it is worth the effort for a single install, so unless you want to participate to some distribution packaging and share your experiments, double installing is currently usually preferable.
Note that you can install a Python library in Sage by typing from a terminal:
sage -pip install some_lib
Sat, 23 Jan 2016 23:49:15 +0100https://ask.sagemath.org/question/32321/how-to-use-libraries-installed-in-for-python-in-sage/?answer=32323#post-id-32323Answer by ebraminio for <p>I've installed some libraries to the 'normal' or 'system' Python on my computer.</p>
<p>However, Sage cannot see them.</p>
<p>How can I get Sage to use the libraries installed for Python? I'd prefer not to double install for Python and Sage separately.</p>
<hr/>
<p>I've noticed that Sage uses some Python from the Sage package. Which is clearly different than the one I'm using as "system Python". Is there a way to make these the same?</p>
https://ask.sagemath.org/question/32321/how-to-use-libraries-installed-in-for-python-in-sage/?answer=38620#post-id-38620I know this is not considered a clean and good workaround but at least works for me as issuing pip from sage is somehow seem broken for me and my tries for fixing it failed: just put this line on top of your script `import sys; sys.path.append('/usr/local/lib/python2.7/site-packages')` (or any other appropriate place your python 2 packages are installed), for example see:
~ sage --python
import Python 2.7.13 (default, Mar 25 2017, 16:37:39)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.42.1)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named requests
>>> import sys; sys.path.append('/usr/local/lib/python2.7/site-packages')
>>>
>>> import requests
>>>
>>> Tue, 22 Aug 2017 15:54:06 +0200https://ask.sagemath.org/question/32321/how-to-use-libraries-installed-in-for-python-in-sage/?answer=38620#post-id-38620