Note that Sage ships its own Python, which is distinct from your system-wide Python.
The packages installed for Sage's Python have no influence on your system-wide Python.
The packages installed for your system-wide Python have no influence on Sage's Python.
To start Sage's Python, run sage -python
or sage -ipython
in a terminal.
Sage's Python comes equipped with many packages (numpy, scipy, sympy, etc).
Some of them are imported by Sage at startup, some are not. For instance,
even though they are standard packages, numpy and scipy are not imported
by Sage at startup. To use them in Sage, you need an explicit import
.
Optional packages (such as igraph) need to be installed first.
After you have installed some new packages for Sage, restart Sage's Python
and you can import them.
In the case of igraph
and python_igraph
, it seems that you need
to install both, but to use them you only need to type import igraph
.
Before:
$ sage -ipython
Python 2.7.10 (default, Oct 26 2016, 00:37:24)
Type "copyright", "credits" or "license" for more information.
IPython 5.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import numpy
In [2]: import scipy
In [3]: import sage
In [4]: import igraph
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-5-8e950eb5d8d8> in <module>()
----> 1 import igraph
ImportError: No module named igraph
Installing:
$ sage -i igraph
...
[igraph-0.7.1] Finished installing igraph-0.7.1.spkg
real 3m23.309s
user 7m38.410s
sys 1m6.209s
Sage build/upgrade complete!
$ sage -i python_igraph
...
Sage build/upgrade complete!
$
After:
$ sage -ipython
Python 2.7.10 (default, Oct 26 2016, 00:37:24)
Type "copyright", "credits" or "license" for more information.
IPython 5.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: import igraph
In [2]: