Igraph在Python控制台中运行,但不是从脚本运行

问题描述 投票:0回答:1

我已经在https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-igraph处使用转盘在Python 3.7.2上安装了igraph,并“ pip install python-igraph”。我试图用以下方法创建一个简单的图形:

import igraph
g = igraph.Graph()

[当我在控制台(IDLE)中运行它时有效,但是当我在脚本中编写并执行它时,第二个命令给出以下错误:

Traceback (most recent call last):
  File "path\igraph.py", line 1, in <module>
    import igraph
  File "path\igraph.py", line 3, in <module>
    g = igraph.Graph()
AttributeError: module 'igraph' has no attribute 'Graph'

以前我错误地使用了'pip install igraph“,但后来将其卸载了。

python igraph
1个回答
1
投票

[最有可能,您将可执行文件命名为igraph.py,因此存在名称冲突。只需重命名文件

© www.soinside.com 2019 - 2024. All rights reserved.