I installed the igraph python library using pip
JavaScript
x
2
1
sudo pip install python-igraph
2
I go on the Python console/terminal and import the module
JavaScript
1
6
1
$ python
2
Python 2.7.4 (default, Sep 26 2013, 03:20:26)
3
[GCC 4.7.3] on linux2
4
Type "help", "copyright", "credits" or "license" for more information.
5
>>> import igraph
6
No problem. Then I test to see the version number
JavaScript
1
3
1
>>> print igraph.__version__
2
0.6
3
No problem there either. But when I try to create a script.
JavaScript
1
3
1
from igraph import *
2
g = Graph()
3
And execute
JavaScript
1
2
1
python2.7 script.py
2
or
JavaScript
1
2
1
python script.py
2
All i get is
JavaScript
1
7
1
Traceback (most recent call last):
2
File "script.py", line 1, in <module>
3
from igraph import *
4
File ".../script.py", line 2, in <module>
5
g = Graph()
6
NameError: name 'Graph' is not defined
7
Advertisement
Answer
Try this, as your script:
JavaScript
1
3
1
import igraph
2
g = igraph.Graph(1)
3
Global imports are generally not encouraged.