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