Vlad Gheorghe
Vlad Gheorghe

Reputation: 480

Igraph runs in Python console but not from script

I've installed igraph on Python 3.7.2 using the wheel at https://www.lfd.uci.edu/~gohlke/pythonlibs/#python-igraph and 'pip install python-igraph'. I attempted to create a simple graph with:

import igraph
g = igraph.Graph()

This works when I run it in the console (IDLE) but when I write it in a script and execute it, the second command gives the following error:

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'

Previously I wrongly used 'pip install igraph" but later uninstalled it.

Upvotes: 0

Views: 161

Answers (1)

Alex Burkov
Alex Burkov

Reputation: 161

Most likely, you named your executable file igraph.py, so there is a name conflict. Just rename the file

Upvotes: 1

Related Questions