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

Margaret McDaniel picture Margaret McDaniel · Mar 20, 2015 · Viewed 7.8k times · Source

I have installed igraph on Pycharm for Windows.

import igraph

yields no errors.

import igraph
print igraph.__version__

yields: 0.1.5.

import igraph
dir(igraph)

yields nothing...

import igraph
g = igraph.Graph(1)

yields:

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'

Does anyone know what the issue might be? I've looked at all the previously asked questions I could find and I haven't found an answer that will work for my case. Thanks.

Answer

Peter Wood picture Peter Wood · Mar 20, 2015

There are two igraph libraries on PyPI, igraph and python-igraph.

You have igraph installed, which is the wrong one. Uninstall it using:

pip uninstall igraph

As you are on Windows you probably need a pre-compiled distribution, called a wheel.

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

Install using, e.g.:

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