安装Python igraph时出现问题

2024-03-29 05:42:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用pip安装了igraph python库

sudo pip install python-igraph

我进入Python控制台/终端并导入模块

$ 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

没问题。然后我测试看看版本号

>>> print igraph.__version__
0.6

也没问题。但当我试图创作一个脚本。

from igraph import *
g = Graph()

执行

python2.7 script.py

或者

python script.py

我得到的只是

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

Tags: 模块installpipinfrompyimport终端