Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

python-Igraph failed to build C core. #598

Closed
v3ss0n opened this issue Mar 18, 2014 · 51 comments
Closed

python-Igraph failed to build C core. #598

v3ss0n opened this issue Mar 18, 2014 · 51 comments

Comments

@v3ss0n
Copy link

v3ss0n commented Mar 18, 2014

$ python setup.py build
running build
running build_py
running build_ext
Cannot find the C core of igraph on this system using pkg-config.
Build type: static extension
Include path: igraphcore/include
Library path: igraphcore/lib /usr/local/lib64 /usr/local/lib /usr/lib64 /usr/lib /lib64 /lib
Linked dynamic libraries: xml2 stdc++
Linked static libraries: igraphcore/lib/libigraph.a /usr/lib64/libz.a /usr/lib64/libm.a
Extra compiler options:
Extra linker options:
building 'igraph._igraph' extension
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/src
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/indexing.c -o build/temp.linux-x86_64-2.7/src/indexing.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/py2compat.c -o build/temp.linux-x86_64-2.7/src/py2compat.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/edgeseqobject.c -o build/temp.linux-x86_64-2.7/src/edgeseqobject.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/common.c -o build/temp.linux-x86_64-2.7/src/common.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/pyhelpers.c -o build/temp.linux-x86_64-2.7/src/pyhelpers.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/edgeobject.c -o build/temp.linux-x86_64-2.7/src/edgeobject.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/random.c -o build/temp.linux-x86_64-2.7/src/random.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/graphobject.c -o build/temp.linux-x86_64-2.7/src/graphobject.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/attributes.c -o build/temp.linux-x86_64-2.7/src/attributes.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/vertexobject.c -o build/temp.linux-x86_64-2.7/src/vertexobject.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/arpackobject.c -o build/temp.linux-x86_64-2.7/src/arpackobject.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/filehandle.c -o build/temp.linux-x86_64-2.7/src/filehandle.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/vertexseqobject.c -o build/temp.linux-x86_64-2.7/src/vertexseqobject.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/convert.c -o build/temp.linux-x86_64-2.7/src/convert.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/bfsiter.c -o build/temp.linux-x86_64-2.7/src/bfsiter.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/error.c -o build/temp.linux-x86_64-2.7/src/error.o
x86_64-pc-linux-gnu-gcc -pthread -fPIC -Iigraphcore/include -I../../build/include -I../../include -I/usr/local/include/igraph -I/usr/include/igraph -I/usr/include/python2.7 -c src/igraphmodule.c -o build/temp.linux-x86_64-2.7/src/igraphmodule.o
x86_64-pc-linux-gnu-gcc -pthread -shared -Wl,-O1 -Wl,--as-needed -L. build/temp.linux-x86_64-2.7/src/indexing.o build/temp.linux-x86_64-2.7/src/py2compat.o build/temp.linux-x86_64-2.7/src/edgeseqobject.o build/temp.linux-x86_64-2.7/src/common.o build/temp.linux-x86_64-2.7/src/pyhelpers.o build/temp.linux-x86_64-2.7/src/edgeobject.o build/temp.linux-x86_64-2.7/src/random.o build/temp.linux-x86_64-2.7/src/graphobject.o build/temp.linux-x86_64-2.7/src/attributes.o build/temp.linux-x86_64-2.7/src/vertexobject.o build/temp.linux-x86_64-2.7/src/arpackobject.o build/temp.linux-x86_64-2.7/src/filehandle.o build/temp.linux-x86_64-2.7/src/vertexseqobject.o build/temp.linux-x86_64-2.7/src/convert.o build/temp.linux-x86_64-2.7/src/bfsiter.o build/temp.linux-x86_64-2.7/src/error.o build/temp.linux-x86_64-2.7/src/igraphmodule.o igraphcore/lib/libigraph.a /usr/lib64/libz.a /usr/lib64/libm.a -Ligraphcore/lib -L/usr/local/lib64 -L/usr/local/lib -L/usr/lib64 -L/usr/lib -L/lib64 -L/lib -L../../build/src/.libs -L../../src/.libs -L/usr/local/lib -L/usr/lib -L/usr/lib64 -lxml2 -lstdc++ -lpython2.7 -o build/lib.linux-x86_64-2.7/igraph/_igraph.so
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/libm.a(k_standard.o): warning: relocation against __kernel_standard' in readonly section.text'.
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib64/libm.a(s_atan.o): relocation R_X86_64_PC32 against symbol `__atan_sse2' can not be used when making a shared object; recompile with -fPIC
/usr/lib/gcc/x86_64-pc-linux-gnu/4.7.3/../../../../x86_64-pc-linux-gnu/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
error: command 'x86_64-pc-linux-gnu-gcc' failed with exit status 1

@v3ss0n v3ss0n changed the title pythobn-Igraph failed to build C core. pythob-Igraph failed to build C core. Mar 18, 2014
@v3ss0n v3ss0n changed the title pythob-Igraph failed to build C core. python-Igraph failed to build C core. Mar 18, 2014
@ntamas
Copy link
Member

ntamas commented Mar 18, 2014

Can you provide some more details please? Which Linux distribution is it? Is it a 64-bit machine? Have you ever installed the C core of igraph separately on this machine? Or anything else that might help us reproduce the issue.

@v3ss0n
Copy link
Author

v3ss0n commented Mar 19, 2014

  1. I just downloaded igraph and build $python setup.py build, it automatically download C Core but failed to build.
  2. I am using sabayon (Gentoo) linux , 64 bit , i have all the scipy /numpy /matplotlib kit setup completely.
  3. Never installted C Core separately before.

@gaborcsardi
Copy link
Contributor

@v3ss0n
Copy link
Author

v3ss0n commented Mar 19, 2014

I've downloaded 0.7 from pypi.

On Wed, Mar 19, 2014 at 8:19 PM, Gabor Csardi notifications@github.comwrote:

Downloaded from where? igraph.sf.net? igraph.org?
https://pypi.python.org/pypi/python-igraph? igraph.org/nightly? What
version?


Reply to this email directly or view it on GitHubhttps://github.com//issues/598#issuecomment-38052108
.

@ntamas
Copy link
Member

ntamas commented Mar 19, 2014

Okay, let me install Sabayon Linux in a VM so I can test it myself.

@v3ss0n
Copy link
Author

v3ss0n commented Mar 19, 2014

Thanks thats very cool!

On Wed, Mar 19, 2014 at 8:50 PM, Tamás Nepusz notifications@github.comwrote:

Okay, let me install Sabayon Linux in a VM so I can test it myself.


Reply to this email directly or view it on GitHubhttps://github.com//issues/598#issuecomment-38055511
.

@ntamas
Copy link
Member

ntamas commented Mar 21, 2014

This is just a workaround as I have yet to figure out what the exact problem is, but temporarily renaming /usr/lib64/libm.a to something like /usr/lib64/libm.a.disabled and renaming it back after compilation does the trick for me. Make sure to run python -m igraph.test.__init__ after installation to make sure that everything works fine.

For the record: I should also ensure that the C core of igraph is downloaded and compiled in a temporary directory that is not in /tmp because /tmp is mounted with noexec by default on Sabayon Linux.

@v3ss0n
Copy link
Author

v3ss0n commented Mar 21, 2014

Thanks a lot , i will test it out.

On Fri, Mar 21, 2014 at 5:04 PM, Tamás Nepusz notifications@github.comwrote:

This is just a workaround as I have yet to figure out what the exact
problem is, but temporarily renaming /usr/lib64/libm.a to something like
/usr/lib64/libm.a.disabled and renaming it back after compilation does
the trick for me. Make sure to run python -m igraph.test.init after
installation to make sure that everything works fine.

For the record: I should also ensure that the C core of igraph is
downloaded and compiled in a temporary directory that is not in /tmpbecause
/tmp is mounted with noexec by default on Sabayon Linux.


Reply to this email directly or view it on GitHubhttps://github.com//issues/598#issuecomment-38264291
.

@ntamas
Copy link
Member

ntamas commented Mar 25, 2014

Added several refinements to setup.pyin bb5964f that should resolve the issues with Sabayon Linux.

@ntamas ntamas closed this as completed Mar 25, 2014
@v3ss0n
Copy link
Author

v3ss0n commented Sep 1, 2014

Thanks i will test it , right now i am using graph-tool , its a lot harder than igraph tho.

@salvatoreloguercio
Copy link

Hi Tamas, I had similar issues when trying to install igraph 0.7 (python-igraph) in a virtualenv on Ubuntu 14.04 LTS. How can I install the fix you added? Thanks, Sal

@ntamas
Copy link
Member

ntamas commented Oct 8, 2014

The easiest is probably to download python-igraph-0.7.tar.gz from PyPI, replace setup.py with its patched version and then run python setup.py install.

@neuralyzer
Copy link

I had similar problems running Arch linux. libm.a is compiled without the -fPIC flag. I also tried the patched setup.py from the develop branch. However it did not work for me. While compilation worked I could not import igraph in Python I got an error that _igraph.so is missing.

@ntamas
Copy link
Member

ntamas commented Oct 8, 2014

This is probably because you were still standing in the folder where the Python interface was compiled. That folder has an igraph subfolder, so when Python reaches import igraph._igraph, it tries to find _igraph.so in the igraph subfolder of the source tree and not in the place where the Python interface was installed. You have to change to some other directory and then it should work.

@neuralyzer
Copy link

Thanks. Making sure my working directory is different from the install directory I get the following error message

>>> import igraph
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/site-packages/igraph/__init__.py", line 34, in <module>
    from igraph._igraph import *
ImportError: /usr/lib/python2.7/site-packages/igraph/_igraph.so: undefined symbol: _ZTVN10__cxxabiv121__vmi_class_type_infoE

(I downloaded igraph 0.7 from PyPI and replaced setup.py by the patched file you linked)

@salvatoreloguercio
Copy link

Thanks. I ended up doing the following and python-igraph seems to work now:

wget http://igraph.org/nightly/get/c/igraph-0.7.1.tar.gz
wget http://igraph.org/nightly/get/python/python-igraph-0.7.0.tar.gz
tar xzf igraph-0.7.1.tar.gz
tar xzf python-igraph-0.7.0.tar.gz

cd igraph-0.7.0
./configure
make
sudo make install

#on the python folder
cd ../python-igraph-0.7.0
python setup.py build
sudo python setup.py

# add LD_LIBRARY_PATH for .so files
export LD_LIBRARY_PATH=/usr/local/lib/

(Ubuntu 14.04 LTS)

@neuralyzer
Copy link

Did you try to run the unittests? While I can install igraph and python-igraph this way without error messages I get a segmentation fault (core dumped) when running the unittests. Here is the output:

igraph.test.run_tests(2)
testAddEdges (igraph.test.basic.BasicTests) ... ok
testAddVertex (igraph.test.basic.BasicTests) ... ok
testAddVertices (igraph.test.basic.BasicTests) ... ok
testAdjacency (igraph.test.basic.BasicTests) ... ok
testDeleteEdges (igraph.test.basic.BasicTests) ... ok
testDeleteVertices (igraph.test.basic.BasicTests) ... ok
testEdgeIncidency (igraph.test.basic.BasicTests) ... ok
testGraphCreation (igraph.test.basic.BasicTests) ... ok
testGraphGetEids (igraph.test.basic.BasicTests) ... ok
testMultiplesLoops (igraph.test.basic.BasicTests) ... ok
testPickling (igraph.test.basic.BasicTests) ... ok
testMatrix (igraph.test.basic.DatatypeTests) ... ok
testGraphFromDictIterator (igraph.test.basic.GraphDictListTests) ... ok
testGraphFromDictIteratorNoVertices (igraph.test.basic.GraphDictListTests) ... ok
testGraphFromDictList (igraph.test.basic.GraphDictListTests) ... ok
testGraphFromDictListAlternativeName (igraph.test.basic.GraphDictListTests) ... ok
testGraphFromDictListExtraVertexName (igraph.test.basic.GraphDictListTests) ... ok
testGraphFromTupleList (igraph.test.basic.GraphTupleListTests) ... ok
testGraphFromTupleListWithDifferentNameAttribute (igraph.test.basic.GraphTupleListTests) ... ok
testGraphFromTupleListWithEdgeAttributes (igraph.test.basic.GraphTupleListTests) ... ok
testGraphFromTupleListWithWeights (igraph.test.basic.GraphTupleListTests) ... ok
testNoneForMissingAttributes (igraph.test.basic.GraphTupleListTests) ... ok
testIsDegreeSequence (igraph.test.basic.DegreeSequenceTests) ... ok
testIsGraphicalSequence (igraph.test.basic.DegreeSequenceTests) ... ok
testBoundaries (igraph.test.layouts.LayoutTests) ... ok
testBoundingBox (igraph.test.layouts.LayoutTests) ... ok
testCenter (igraph.test.layouts.LayoutTests) ... ok
testCentroid (igraph.test.layouts.LayoutTests) ... ok
testConstructor (igraph.test.layouts.LayoutTests) ... ok
testFitInto (igraph.test.layouts.LayoutTests) ... ok
testIndexing (igraph.test.layouts.LayoutTests) ... ok
testScaling (igraph.test.layouts.LayoutTests) ... ok
testToPolar (igraph.test.layouts.LayoutTests) ... ok
testTransform (igraph.test.layouts.LayoutTests) ... ok
testTranslation (igraph.test.layouts.LayoutTests) ... ok
testAuto (igraph.test.layouts.LayoutAlgorithmTests) ... ok
testBipartite (igraph.test.layouts.LayoutAlgorithmTests) ... ok
testDRL (igraph.test.layouts.LayoutAlgorithmTests) ... ok
testFruchtermanReingold (igraph.test.layouts.LayoutAlgorithmTests) ... ok
testKamadaKawai (igraph.test.layouts.LayoutAlgorithmTests) ... ok
testMDS (igraph.test.layouts.LayoutAlgorithmTests) ... ok
testReingoldTilford (igraph.test.layouts.LayoutAlgorithmTests) ... ok
testDeBruijn (igraph.test.generators.GeneratorTests) ... ok
testFamous (igraph.test.generators.GeneratorTests) ... ok
testFormula (igraph.test.generators.GeneratorTests) ... ok
testFull (igraph.test.generators.GeneratorTests) ... ok
testFullCitation (igraph.test.generators.GeneratorTests) ... ok
testKautz (igraph.test.generators.GeneratorTests) ... ok
testLCF (igraph.test.generators.GeneratorTests) ... ok
testSBM (igraph.test.generators.GeneratorTests) ... ok
testStar (igraph.test.generators.GeneratorTests) ... ok
testWeightedAdjacency (igraph.test.generators.GeneratorTests) ... ok
testAsymmetricPreference (igraph.test.games.GameTests) ... ok
testForestFire (igraph.test.games.GameTests) ... ok
testGRG (igraph.test.games.GameTests) ... ok
testPreference (igraph.test.games.GameTests) ... ok
testRandomBipartiteNM (igraph.test.games.GameTests) ... ok
testRandomBipartiteNP (igraph.test.games.GameTests) ... ok
testRecentDegree (igraph.test.games.GameTests) ... ok
testRewire (igraph.test.games.GameTests) ... ok
testWattsStrogatz (igraph.test.games.GameTests) ... ok
testAdjacency (igraph.test.foreign.ForeignTests) ... ok
testDIMACS (igraph.test.foreign.ForeignTests) ... ok
testDL (igraph.test.foreign.ForeignTests) ... ok
testLGL (igraph.test.foreign.ForeignTests) ... ok
testNCOL (igraph.test.foreign.ForeignTests) ... ok
testPickle (igraph.test.foreign.ForeignTests) ... ok
testAvgLocalTransitivity (igraph.test.structural.SimplePropertiesTests) ... ok
testDensity (igraph.test.structural.SimplePropertiesTests) ... ok
testDiameter (igraph.test.structural.SimplePropertiesTests) ... ok
testEccentricity (igraph.test.structural.SimplePropertiesTests) ... ok
testLocalTransitivity (igraph.test.structural.SimplePropertiesTests) ... ok
testModularity (igraph.test.structural.SimplePropertiesTests) ... ok
testRadius (igraph.test.structural.SimplePropertiesTests) ... ok
testTransitivity (igraph.test.structural.SimplePropertiesTests) ... ok
testDegree (igraph.test.structural.DegreeTests) ... ok
testKnn (igraph.test.structural.DegreeTests) ... ok
testMaxDegree (igraph.test.structural.DegreeTests) ... ok
testStrength (igraph.test.structural.DegreeTests) ... ok
testLocalTransitivityFull (igraph.test.structural.LocalTransitivityTests) ... ok
testLocalTransitivityHalf (igraph.test.structural.LocalTransitivityTests) ... ok
testLocalTransitivityPartial (igraph.test.structural.LocalTransitivityTests) ... ok
testLocalTransitivityTree (igraph.test.structural.LocalTransitivityTests) ... ok
testArticulationPoints (igraph.test.structural.BiconnectedComponentTests) ... ok
testBiconnectedComponents (igraph.test.structural.BiconnectedComponentTests) ... ok
testAuthorityScore (igraph.test.structural.CentralityTests) ... ok
testBetweennessCentrality (igraph.test.structural.CentralityTests) ... ok
testClosenessCentrality (igraph.test.structural.CentralityTests) ... ok
testCoreness (igraph.test.structural.CentralityTests) ... ok
testEdgeBetweennessCentrality (igraph.test.structural.CentralityTests) ... ok
testEigenvectorCentrality (igraph.test.structural.CentralityTests) ... ok
testHubScore (igraph.test.structural.CentralityTests) ... ok
testPageRank (igraph.test.structural.CentralityTests) ... Segmentation fault (core dumped)

@salvatoreloguercio
Copy link

Ugh, good point - got the same segfault error here :(

testPageRank (igraph.test.structural.CentralityTests) ... Segmentation fault (core dumped)

@ntamas
Copy link
Member

ntamas commented Oct 21, 2014

You are probably running into this:

#636

It has been fixed since the release in the following commit:

923974d

It happens only if you use Graph.pagerank(), but running Graph.personalized_pagerank() in place of pagerank() is fine (and the default arguments for Graph.personalized_pagerank() are equivalent to Graph.pagerank()).

@ayushidalmia
Copy link

Is this issue resolved yet? I still ran into the same bug while using it on Ubuntu 64 bit machine while trying to install using pip. I have not installed the C-core separately

Also, the patched version is not available.

@ntamas
Copy link
Member

ntamas commented Jan 11, 2016

The comments above mention several bugs and you did not specify which one you meant. Which bug are you running into?

For what it's worth, I have successfully built python-igraph from scratch in a Docker container running Ubuntu 14.04 right now, without problems.

@ayushidalmia
Copy link

I was talking about the "failed to build C core." issue. I could also install using apt-get. Using pip is problematic.

@ntamas
Copy link
Member

ntamas commented Jan 11, 2016

Yes, but does pip fail or does it succeed and then fails later when you invoke the unit tests? What does pip print exactly on the console?

@ayushidalmia
Copy link

The following is the output:

Could not download and compile the C core of igraph.


Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;file='/tmp/pip-build-1jTFRm/python-igraph/setup.py';exec(compile(getattr(tokenize, 'open', open)(file).read().replace('\r\n', '\n'), file, 'exec'))" install --record /tmp/pip-YyjBlR-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /tmp/pip-build-1jTFRm/python-igraph
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in
load_entry_point('pip==1.5.6', 'console_scripts', 'pip')()
File "/usr/lib/python2.7/dist-packages/pip/init.py", line 248, in main
return command.main(cmd_args)
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 161, in main
text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 32: ordinal not in range(128)

@ntamas
Copy link
Member

ntamas commented Jan 11, 2016

This is a different bug, unrelated to the ones listed above. The problem is actually that you will have to install libxml2-dev in order to compile the C core of igraph (because the GraphML reader needs it). This is reported correctly by the install log, the problem is that pip has a bug that hides this and reports the UnicodeDecodeError above (due to an obscure character that is present somewhere in the compiler output).

@ayushidalmia
Copy link

Still can't get through: This is the error.

In file included from src/edgeobject.c:25:0:
src/attributes.h:26:20: fatal error: Python.h: No such file or directory
compilation terminated.
error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

I think it is best not to use pip but apt-get

@ntamas
Copy link
Member

ntamas commented Jan 11, 2016

You also need python-dev if you want to compile any Python module.

Also, apt-get will not get you the latest version of the python-igraph module but the one that comes bundled (and precompiled) with Ubuntu by default. You have to use pip if you need the latest version.

@kaivalyar
Copy link

Hi,

Is the installation with pip issue resolved yet? I am running Linux Mint, and trying to install python-igraph in a virtual environment. I keep getting this error, despite having libigraph0-dev and libxml2-dev installed.

(venv) ... $ pip install python-igraph
Downloading/unpacking python-igraph
  Downloading python-igraph-0.7.1.post6.tar.gz (377kB): 377kB downloaded
  Running setup.py (path:/home/kaivalya/venv/build/python-igraph/setup.py) egg_info for package python-igraph

Installing collected packages: python-igraph
  Running setup.py install for python-igraph
    Build type: dynamic extension
    Include path: /usr/include/igraph
    Library path: /usr/lib/x86_64-linux-gnu
    Runtime library path:
    Linked dynamic libraries: igraph
    Linked static libraries:
    Extra compiler options:
    Extra linker options:
    building 'igraph._igraph' extension
    x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/igraph -I/usr/include/python2.7 -c src/indexing.c -o build/temp.linux-x86_64-2.7/src/indexing.o
    In file included from src/indexing.c:25:0:
    src/convert.h:65:59: error: unknown type name ‘igraph_pagerank_algo_t’
     int igraphmodule_PyObject_to_pagerank_algo_t(PyObject *o, igraph_pagerank_algo_t *result);
                                                               ^
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1
    Complete output from command /home/kaivalya/venv/bin/python -c "import setuptools, tokenize;__file__='/home/kaivalya/venv/build/python-igraph/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zfUz__-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/kaivalya/venv/include/site/python2.7:
    running install

running build

running build_py

creating build

creating build/lib.linux-x86_64-2.7

creating build/lib.linux-x86_64-2.7/igraph

copying igraph/compat.py -> build/lib.linux-x86_64-2.7/igraph

copying igraph/datatypes.py -> build/lib.linux-x86_64-2.7/igraph

copying igraph/matching.py -> build/lib.linux-x86_64-2.7/igraph

copying igraph/statistics.py -> build/lib.linux-x86_64-2.7/igraph

copying igraph/layout.py -> build/lib.linux-x86_64-2.7/igraph

copying igraph/formula.py -> build/lib.linux-x86_64-2.7/igraph

copying igraph/summary.py -> build/lib.linux-x86_64-2.7/igraph

copying igraph/cut.py -> build/lib.linux-x86_64-2.7/igraph

copying igraph/configuration.py -> build/lib.linux-x86_64-2.7/igraph

copying igraph/__init__.py -> build/lib.linux-x86_64-2.7/igraph

copying igraph/clustering.py -> build/lib.linux-x86_64-2.7/igraph

copying igraph/utils.py -> build/lib.linux-x86_64-2.7/igraph

creating build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/isomorphism.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/matching.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/basic.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/vertexseq.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/attributes.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/foreign.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/operators.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/generators.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/bipartite.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/layouts.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/edgeseq.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/games.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/structural.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/atlas.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/colortests.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/decomposition.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/cliques.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/indexing.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/flow.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/__init__.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/iterators.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/conversion.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/spectral.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/homepage.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/separators.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/rng.py -> build/lib.linux-x86_64-2.7/igraph/test

copying igraph/test/utils.py -> build/lib.linux-x86_64-2.7/igraph/test

creating build/lib.linux-x86_64-2.7/igraph/app

copying igraph/app/shell.py -> build/lib.linux-x86_64-2.7/igraph/app

copying igraph/app/__init__.py -> build/lib.linux-x86_64-2.7/igraph/app

creating build/lib.linux-x86_64-2.7/igraph/drawing

copying igraph/drawing/text.py -> build/lib.linux-x86_64-2.7/igraph/drawing

copying igraph/drawing/shapes.py -> build/lib.linux-x86_64-2.7/igraph/drawing

copying igraph/drawing/graph.py -> build/lib.linux-x86_64-2.7/igraph/drawing

copying igraph/drawing/vertex.py -> build/lib.linux-x86_64-2.7/igraph/drawing

copying igraph/drawing/edge.py -> build/lib.linux-x86_64-2.7/igraph/drawing

copying igraph/drawing/colors.py -> build/lib.linux-x86_64-2.7/igraph/drawing

copying igraph/drawing/coord.py -> build/lib.linux-x86_64-2.7/igraph/drawing

copying igraph/drawing/__init__.py -> build/lib.linux-x86_64-2.7/igraph/drawing

copying igraph/drawing/metamagic.py -> build/lib.linux-x86_64-2.7/igraph/drawing

copying igraph/drawing/baseclasses.py -> build/lib.linux-x86_64-2.7/igraph/drawing

copying igraph/drawing/utils.py -> build/lib.linux-x86_64-2.7/igraph/drawing

creating build/lib.linux-x86_64-2.7/igraph/remote

copying igraph/remote/gephi.py -> build/lib.linux-x86_64-2.7/igraph/remote

copying igraph/remote/__init__.py -> build/lib.linux-x86_64-2.7/igraph/remote

copying igraph/remote/nexus.py -> build/lib.linux-x86_64-2.7/igraph/remote

creating build/lib.linux-x86_64-2.7/igraph/vendor

copying igraph/vendor/texttable.py -> build/lib.linux-x86_64-2.7/igraph/vendor

copying igraph/vendor/__init__.py -> build/lib.linux-x86_64-2.7/igraph/vendor

running build_ext

Build type: dynamic extension

Include path: /usr/include/igraph

Library path: /usr/lib/x86_64-linux-gnu

Runtime library path:

Linked dynamic libraries: igraph

Linked static libraries:

Extra compiler options:

Extra linker options:

building 'igraph._igraph' extension

creating build/temp.linux-x86_64-2.7

creating build/temp.linux-x86_64-2.7/src

x86_64-linux-gnu-gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/igraph -I/usr/include/python2.7 -c src/indexing.c -o build/temp.linux-x86_64-2.7/src/indexing.o

In file included from src/indexing.c:25:0:

src/convert.h:65:59: error: unknown type name ‘igraph_pagerank_algo_t’

 int igraphmodule_PyObject_to_pagerank_algo_t(PyObject *o, igraph_pagerank_algo_t *result);

                                                           ^

error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

----------------------------------------
Cleaning up...
Command /home/kaivalya/venv/bin/python -c "import setuptools, tokenize;__file__='/home/kaivalya/venv/build/python-igraph/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-zfUz__-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/kaivalya/venv/include/site/python2.7 failed with error code 1 in /home/kaivalya/venv/build/python-igraph
Traceback (most recent call last):
  File "/home/kaivalya/venv/bin/pip", line 11, in <module>
    sys.exit(main())
  File "/home/kaivalya/venv/local/lib/python2.7/site-packages/pip/__init__.py", line 185, in main
    return command.main(cmd_args)
  File "/home/kaivalya/venv/local/lib/python2.7/site-packages/pip/basecommand.py", line 161, in main
    text = '\n'.join(complete_log)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 50: ordinal not in range(128)

@ntamas
Copy link
Member

ntamas commented Nov 18, 2016

I keep getting this error, despite having libigraph0-dev and libxml2-dev installed
Most likely the version of libigraph0-dev on your machine does not match the version of python-igraph, that's why you are getting this error during compilation:

src/convert.h:65:59: error: unknown type name ‘igraph_pagerank_algo_t’
 int igraphmodule_PyObject_to_pagerank_algo_t(PyObject *o, igraph_pagerank_algo_t *result);

(The UnicodeDecodeError at the end is irrelevant).

Try uninstalling libigraph0-dev and libigraph0, which will force the Python setup script to download the matching version of the C core of igraph and link it statically to the Python extension being compiled.

@kaivalyar
Copy link

Thank you, this worked!

I had tried pip installing python-igraph before, but it had failed. Then I manually installed libigraph, and retried, with the error mentioned above. Now upon uninstalling libigraph as suggested, I was able to install successfully. Thank you very much.

@JoshMJacobson
Copy link

Mine is failing on OSX, attempts to install using pip, pip3, easy_install, and homebrew all yield this result:

grep: /usr/lib/libiconv.la: No such file or directory
    sed: /usr/lib/libiconv.la: No such file or directory
    libtool: link: `/usr/lib/libiconv.la' is not a valid libtool archive
    make[3]: *** [libigraph.la] Error 1
    make[2]: *** [all] Error 2
    make[1]: *** [all-recursive] Error 1
    make: *** [all] Error 2
    Could not download and compile the C core of igraph.


    ----------------------------------------
    Command "//anaconda/bin/python -u -c "import setuptools,
 tokenize;__file__='/private/var/folders/py/84q2xtqd7_32k8zh940lp_180000gn/T/pip-
build-sc8w44f8/python-igraph/setup.py';f=getattr(tokenize, 'open', open)
(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, 
__file__, 'exec'))" install --record 
/var/folders/py/84q2xtqd7_32k8zh940lp_180000gn/T/pip-ttmy3g88-record/install-
record.txt --single-version-externally-managed --compile" failed with error code 1 
in /private/var/folders/py/84q2xtqd7_32k8zh940lp_180000gn/T/pip-build-
sc8w44f8/python-igraph/

@ntamas
Copy link
Member

ntamas commented Dec 13, 2016

@JoshMJacobson this is probably a sign of leftover files from previous installations of other pieces of software that contain .la files referring to /usr/lib/libiconv.la (that does not exist on a default Mac OS X installation).

Try installing the C core of igraph first from Homebrew (i.e. brew install igraph). If that fails, run brew doctor to point out some issues on your machine that could interfere with the compilation process.

@ntamas
Copy link
Member

ntamas commented Dec 14, 2016 via email

@Yanxiangxiang
Copy link

Traceback (most recent call last):
File "", line 1, in
File "build/bdist.linux-x86_64/egg/igraph/init.py", line 34, in

File "build/bdist.linux-x86_64/egg/igraph/_igraph.py", line 7, in
File "build/bdist.linux-x86_64/egg/igraph/_igraph.py", line 6, in bootstrap
ImportError: /exportfs/home/liang5/.cache/Python-Eggs/python_igraph-0.7.1.post6-py2.7-linux-x86_64.egg-tmp/igraph/_igraph.so: undefined symbol: _ZTVN10__cxxabiv121__vmi_class_type_infoE

How to solve this problem?

@joebling
Copy link

joebling commented Mar 9, 2017

@Yanxiangxiang have you solved your problem?

@gabrielet
Copy link

Dear all,

I am trying to install python IGraph on Fedora 25 but I'm stuck with the C core library. I run pip to try to install igraph but this is the output.

Could not download and compile the C core of igraph.   
    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-YpRVrp/python-igraph/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-okD_bv-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-YpRVrp/python-igraph/

I also downloaded the source code from the igraph website (i.e. python-igraph-0.7.1.post6.tar.gz) and tried to run this package with pip too. I get the same error as above.

I also tried to extract the tar package and run this command:

$ python setup.py build
with a very similar result: Could not download and compile the C core of igraph.
At this stage I verified if gcc is installed and yes, it is.

Any suggestion?

thanks in advance

@ntamas
Copy link
Member

ntamas commented Jul 14, 2017

Please post the full output of pip install python-igraph. (You can upload it as a gist and then link it here if it is too long).

@gabrielet
Copy link

@ntamas
here is the link at the gist: https://gist.github.com/gabrielet/a050e8ac272b50ada9446ebadbfc5391
thank you for any information!

@ntamas
Copy link
Member

ntamas commented Jul 14, 2017

You need to install libxml2-dev and libz-dev before installing igraph. (Not sure whether these are the right package names for your distro; basically you need the development libraries for libxml2 and libz).

@gabrielet
Copy link

@ntamas
ok, I tried doing as you suggested so I installed the libxml2 library. As far as I understood, by googling it, the libz-dev in Fedora is called zlib-devel and is already installed in my system. But, igraph cannot be installed. I suppose you suggested the libxml2 since in the file I linked there is something like: "Cannot find..." so i searched here (https://gist.github.com/gabrielet/c50c94a97c9ffcb68b2546bd2eff7731). There is a similar line but what the installer can't find this time is the C core. At least the error changed.
Any other ideas?

PS for other users that may found this useful:
the libxml2 library, in Fedora, seems to be libxml2-devel

@ntamas
Copy link
Member

ntamas commented Jul 14, 2017

You also need the development libraries for Python itself if you want to compile a C extension for Python. It should be called something like python-devel on Fedora.

@gabrielet
Copy link

@ntamas
done! many thanks you for your support.
I have just another question: where could I find the information you gave me? Have you found everything in the output files I attached?

@ntamas
Copy link
Member

ntamas commented Jul 17, 2017

Yes; basically the compilation output always pinpointed a few libraries that were missing from your machine.

@gabrielet
Copy link

gabrielet commented Jul 18, 2017

@ntamas
ok, then i'll look into it and see what I can find out!

thank you for your help!

@snazari
Copy link

snazari commented Jan 15, 2018

Im installing on Ubuntu 16.04 LTS and I have the issue "cannot find lxml2". Please see attached output.
output.txt

@ntamas
Copy link
Member

ntamas commented Jan 15, 2018

You need to install libxml2-dev before compiling the Python interface.

@mticlla
Copy link

mticlla commented Sep 20, 2018

Try installing a pre-built binary from https://anaconda.org/marufr/python-igraph - others have reported that it works, but I haven't tried it myself.

This worked for me
conda install -c marufr python-igraph

@rdauria
Copy link

rdauria commented Apr 18, 2019

I can install python-igraph no problems using python/2.7.13, but it will not install in python/3.7.0, here is the error:

` Cannot find the C core of igraph on this system using pkg-config.
We will now try to download and compile the C core from scratch.
Version number of the C core: 0.7.1.post6
We will also try: 0.7.1

Version 0.7.1.post6 of the C core of igraph is not found among the nightly builds.
Use the --c-core-version switch to try a different version.

Could not download and compile the C core of igraph.`

I am on CentOS 6.10, thanks.

@ntamas
Copy link
Member

ntamas commented Apr 23, 2019

python-igraph installs just fine for me in a clean Python 3.7 virtualenv on my machine simply by invoking pip install python-igraph. It downloads the C core, compiles it automatically and links it with the Python interface. Please provide more details about your environment and how you are trying to install python-igraph.

@rschwabco
Copy link

Failed installing with Docker on alpine3.8

FROM tiangolo/uvicorn-gunicorn:python3.7-alpine3.8

RUN apk add --no-cache python3-dev libstdc++
RUN apk add --no-cache g++
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h

RUN apk add --update alpine-sdk make gcc python3-dev python-dev libxslt-dev libxml2-dev libc-dev openssl-dev libffi-dev zlib-dev py-pip openssh libxml2 zlib \
  && rm -rf /var/cache/apk/*

RUN pip3 install python-igraph

COPY ./app /app

Result: https://gist.github.com/squanchd/3fc8139583dea82d53fbeac50cf78003

@ntamas
Copy link
Member

ntamas commented Dec 18, 2019

The vendored f2c library in the latest official tarball of igraph is not compatible with musl libc (which is being used in Alpine Linux).

I have now introduced a few commits in the python-igraph repo that uses a more up-to-date igraph revision from Git and that builds properly on Alpine Linux. You need a slightly tweaked Dockerfile for this (note the extended list of dependencies and the reference to the git repo in pip3 install):

FROM tiangolo/uvicorn-gunicorn:python3.7-alpine3.8

RUN apk add --no-cache python3-dev libstdc++
RUN apk add --no-cache g++
RUN ln -s /usr/include/locale.h /usr/include/xlocale.h

RUN apk add --update alpine-sdk make gcc git python3-dev python-dev libxslt-dev libxml2-dev libc-dev openssl-dev libffi-dev zlib-dev py-pip openssh libxml2 zlib libtool autoconf automake flex bison \
  && rm -rf /var/cache/apk/*

RUN pip3 install git+https://github.com/igraph/python-igraph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests