3

I'm trying to use python's iGraph module on my iMac running OSX 10.9.4. I've followed the steps on igraphs' front page for mac installation bur when I go to import igraph from the terminal, this is what I get.

Python 2.7.5 (default, Mar  9 2014, 22:15:05) 
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)] 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

Here are the steps that I've attempted to install igraph:

I intially had some problems with my pkg-config not being writable (I'm new to homebrew), so I followed these steps

  1. brew install homebrew/science/igraph like posed here and linked the formula with brew link igraph and it brewed with no problems.
  2. pip install python-igraph also finished cleanly.

From the igraphs documentation, this is all I need to do.

I looked into this answer but couldn't get the following line to work.

DYLD_LIBRARY_PATH=/usr/local/lib python -m igraph.test.__init__
/usr/bin/python: No module named igraph.test

This might suggest where the problem is but I don't know where to go from here.

Other information:

I have python installed through brew, but I'm not sure if that is causing the conflict. Regardless, Python2.7 should be the default python. I've installed other modules like numpy, scipy, and matplotlib with no problems.

Let me know if you need/want any other info.

Community
  • 1
  • 1
Austin A
  • 2,990
  • 6
  • 27
  • 42
  • 1
    I'm almost 100% sure that the igraph module is installed for a different Python and not your default Python interpreter (which seems to be the system Python). Look for files named `_igraph.so` on your hard drive, try to figure out which Python they belong to, and then try to run the appropriate Python interpreter. – Tamás Sep 08 '14 at 18:54
  • Thanks @Tamás! I've seen your posts in a few other SO answers I included. So I thought about this too. I've tried to import igraph in Python 2.5, 2.6, 2.7, and 3.4 with no avail. I mentioned above that I installed a python version using homebrew (not sure why, it was a while ago). Thinking that python version might be the problem, I removed that formula from homebrew and then reinstalled igraph. This time I received a compile error at the end of the installation `Command /usr/bin/python -c "import setuptools...blahblahblah`. Any ideas? I may have screwed something up by removing that formula. – Austin A Sep 09 '14 at 02:10
  • 1
    I finally got it working. After realizing that the pip I was using was shipped with homebrew's python. So everything I was pip-ing (<- will be a word some day) was being installed to that instance of python. Like I said above, I uninstalled homebrews python and installed pip to my mac's default python version (2.7.5). I then `pip install python-igraph` got an error, did it again and it worked. Not really sure what happened but all's well that ends well I suppose. Thanks @Tamás! – Austin A Sep 09 '14 at 02:20
  • 1
    I just realized that I subconsciously typed `sudo easy_install python-igraph` instead of `pip install python-igraph` which had a compiler error the first time I tried it. This might hint at some issue wit pip and the Pyhton 2.7.5 that shipped with my iMac. It's most likely to blame on user error though. Let me know if you have anything to add and sorry for comment-bombing my own question. – Austin A Sep 09 '14 at 02:25
  • No problem, I'm glad that it works in the end. – Tamás Sep 09 '14 at 10:42

0 Answers0