user3648650
user3648650

Reputation: 37

igraph python import error

I want to use the python wrapper from igraph. Compiling igraph and installing python-igraph works fine, but when I try to import igraph I get the following error (see image link below):

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/dist-packages/igraph/__init__.py", line 34, in <module>
    from igraph._igraph import *
ImportError: /usr/local/lib/python3.4/dist-packages/igraph/_igraph.cpython-34m.so: undefined symbol: igraph_gomory_hu_tree

Error message screenshot

Upvotes: 2

Views: 3767

Answers (4)

Marguerite
Marguerite

Reputation: 1

FYI: Tried for more than a day with all kinds of resources online for installing python-igraph on mac. And I also wasn't able to import graph in .py file or .ipynb. Though it did allow me to import igraph in terminal when launching python. My solution is to make a virtual environment, conda install -c conda-forge python-igraph, then switch python from version 3.8 (which never passes the igraph.test.run_tests, Failed = 2) to 3.5 (passed the test). Hope it helps.

Upvotes: 0

banermatt
banermatt

Reputation: 43

It's because python doesn't find the igraph library. You can simply export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ (or wherever the file libigraph.so is located on your system).

Upvotes: 0

crs
crs

Reputation: 501

I also had some trouble with igraph and python, my solution:

  1. delete your currently installed version of igraph and python-igraph
  2. create a new virtualenv with pyvenv-3.4 yourVenv
  3. activate the virtualenv . yourVenv/bin/activate
  4. install python-igraph within the virtualenv pip install python-igraph

That one works for me.

Upvotes: 3

WaydeHall
WaydeHall

Reputation: 153

Try using the 'wraptext' import that comes with python. Then use .fill() to wrap the text over the next line. That might work.

Upvotes: 0

Related Questions