Sang Chae
Sang Chae

Reputation: 31

I cannot import igraph on python 2.6 after installation

I installed igraph for python 2.6 on OSX 10.7, but I cannot import igraph library.

It shows a import error:no module name igraph.

I have no idea. Please help me out.

Thanks.

Upvotes: 1

Views: 1489

Answers (1)

abarnert
abarnert

Reputation: 365717

However, I cannot run code with python. I make a code, and tried to run, such as, 'python ex.py'

OK, even though you didn't answer most of my questions, I'm pretty sure I can guess your problem. Your question title is "I cannot import igraph on python 2.6 after installation", but you're not trying to import it on python 2.6, you're trying on 2.7.

$ python
Python 2.7.2 (default, Jun 20 2012, 16:23:33) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named igraph
>>>

$ python2.6
Python 2.6.7 (r267:88850, Jun 20 2012, 16:23:38) 
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import igraph
>>>

See the difference? OS X 10.7 (and 10.8) comes with three versions of Python: 2.5, 2.6, and 2.7. They're entirely independent installations, so when you installed igraph for Python 2.6, that didn't install it for your 2.5 or 2.7 installations.

The default, the one you get when you just run python, is 2.7. If you want a specific version, you have to run python2.6 instead.

So, you either need to run python2.6, or install igraph for 2.7.

As a side note, if you've installed any third-party Python installations, you're going to get yourself even more confused, so please, don't do that (or uninstall if you already have) until you really know what you're doing.

Upvotes: 1

Related Questions