4

I just installed python-igraph 0.7.1 from source with no problems. I didn't already have the C library installed because using the repository version caused errors while building, but setup.py successfully compiled it.

However, now I can't import it. I get the following error:

>>> import igraph
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/jeffcollins/Downloads/python-igraph-0.7.1/igraph/__init__.py", line 34, in <module>
    from igraph._igraph import *
ImportError: No module named 'igraph._igraph'

Prior to my upgrade from trusty to vivid I didn't have this problem, but my install on trusty was long enough ago that I don't remember if anything else relevant has changed (not the Python or python-igraph versions, though).

My system info, if relevant:

  • Samsung Chromebook 2
  • ARMv7 Processor rev 3 (v7l) x4
  • Ubuntu 15.04 (via crouton)
  • Python 3.4.3
JefftheGreen
  • 53
  • 1
  • 5

2 Answers2

3

This usually happens when you are standing right in the folder where you extracted the source tree to. The source tree contains a folder named igraph, but there is no _igraph.so within it - _igraph.so is created in some subfolder of build when you build igraph. When you type import igraph, Python thinks that you meant the igraph folder relative to the current folder, not the igraph package that you have just installed.

Solution: change to another directory that does not have a subfolder named igraph, and try again.

Tamás
  • 47,239
  • 12
  • 105
  • 124
  • I'm getting the same error and my folder structure is: /home/debvrat/research/package_storage/igraph/lib/python3.6/site-packages/igraph/__init__.py The issue is, other users having access to the same folder are able to run the package smoothly. But I'm getting ImportError: No module named 'igraph._igraph'. What could be going wrong? The subfolder issue does not seem to crop up for other users. – Debvrat Varshney May 07 '20 at 05:02
0

I think it might not be python 3.4.3 maybe. Just a thought, since I've tried tons of websites for this on a chromebook. If you could tell me where you downloaded it from, that would help me a lot. :)

  • No, it worked just fine with Tamás's solution. Compiling it by running setup.py with the 3.4.3 interpreter should get you a 3.4.3 version of igraph. – JefftheGreen Sep 26 '15 at 20:59