9

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.

Margaret McDaniel
  • 105
  • 1
  • 1
  • 4
  • I don't know much about the version history of `igraph`, but with 0.7.1, your code works as you expected. Is it possible to update? – jedwards Mar 20 '15 at 05:26
  • So the installation didn't go well... to me `dir(igraph)` returns a bunch of stuff. – Nir Alfasi Mar 20 '15 at 05:26
  • 2
    Did you install it by running: `pip install python-igraph` ? or `pip install igraph` ? you should use the former! in case you ran the latter, it will seem to be installed but it's messed up... – Nir Alfasi Mar 20 '15 at 05:33
  • Are those examples meant to be in the console? If not, you need to `print dir(igraph)`. – Peter Wood Mar 20 '15 at 05:34
  • @alfasin That's it exactly. There are two different packages. `pip install python-igraph` – Peter Wood Mar 20 '15 at 05:56
  • @PeterWood yes, I suspect that the OP installed the wrong one. – Nir Alfasi Mar 20 '15 at 06:00
  • Upon running print dir(igraph) as @PeterWood said, I was able to get output. You all are right about the mistaken installation of the wrong igraph package. However I run into more problems with that as described below. – Margaret McDaniel Mar 21 '15 at 03:55

1 Answers1

13

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
Peter Wood
  • 23,859
  • 5
  • 60
  • 99
  • I have tried doing this, and upon installing it I get an error that says "An operation was attempted on something that is not a socket". I'm assuming I'm doing something wrong though... I have been using Pycharm to run python codes, but I'm assuming I need to be running the 'pip install ... ' from the command prompt? Can you tell me more specifically how I do this correctly? – Margaret McDaniel Mar 21 '15 at 03:53
  • 1
    @MargaretMcDaniel That's another question for another time. I would follow the normal instructions for `pip`. I know PyCharm can install without `pip` being installed in your basic Python installation, so it's possible it won't work from the command line until you install pip separately. You can do that though, it won't affect PyCharm. – Peter Wood Mar 21 '15 at 12:42