python-igraph 中的错误 'module' 对象没有属性 'Graph'

Error in python-igraph 'module' object has no attribute 'Graph'

我已经在 Pycharm 上为 Windows 安装了 igraph。

import igraph

没有错误。

import igraph
print igraph.__version__

产量:0.1.5.

import igraph
dir(igraph)

一无所获...

import igraph
g = igraph.Graph(1)

产量:

Traceback (most recent call last):
File "C:/Users/Margaret/PycharmProjects/untitled/trial.py", line 2, in g = igraph.Graph(1)
AttributeError: 'module' object has no attribute 'Graph'

有人知道问题出在哪里吗?我查看了我能找到的所有先前提出的问题,但没有找到适合我的案例的答案。谢谢。

PyPI 上有两个 igraph 库,igraph and python-igraph

您安装了 igraph,这是错误的。卸载它使用:

pip uninstall igraph

当你在 Windows 时,你可能需要一个预编译的发行版,称为 wheel。

This site has lots of wheels which can be installed using pip. Here is the wheel for python-igraph.

安装使用,例如:

pip install python_igraph-0.7.1.post4-cp27-none-win32.whl