igraph 0.6 installation for Windows 7

Asked by Nybi Clamence

I'm sorry to bring this here since it seems to be a fairly common error (at least for Mac users), but I have been wrestling with it for at least two weeks now.

Since I am running Python 3.2, I am trying to install igraph 0.6, but there seems to be a problem. I have installed Microsoft Visual Express 2008, which didn't do anything, and I then installed MinGW following: http://slacy.com/blog/2010/09/python-unable-to-find-vcvarsall-bat/, but it still does not work.

Basically in my windows cmd (setting the directory to the igraph folder), I write:
- set PATH=C:\MinGW\bin;%PATH%
- setup.py build -c mingw32 install

and I get this:

Using default include and library paths for compilation
If the compilation fails, please edit the LIBIGRAPH_FALLBACK_*
variables in setup.py or include_dirs and library_dirs in
setup.cfg to point to the correct directories and libraries
where the C core of igraph is installed

Include path: /usr/include /usr/local/include
Library path:
C:\Python32\lib\distutils\dist.py:257: UserWarning: Unknown distribution option: 'use_2to3' warnings.warn(msg)
C:\Python32\lib\distutils\dist.py:257: UserWarning: Unknown distribution option: 'test_suite' warnings.warn(msg)
running build
running build_py
running build_ext
building 'igraph._igraph' extension
C:\MinGW\bin\gcc.exe -mno-cygwin -mdll -O -Wall -I/usr/include -I/usr/local/include -I../../build/include:../../include:/usr/local/include:/usr/include -IC:\Python32\include -IC:\Python32\PC -c src\arpackobject.c -o build\temp.win-amd64-3.2\Release\src\arpackobject.o
In file included from src\arpackobject.c:24:
src\arpackobject.h:28:27: igraph_arpack.h: No such file or directory
In file included from src\arpackobject.h:29,
from src\arpackobject.c:24:
src\graphobject.h:28:20: igraph.h: No such file or directory
In file included from src\arpackobject.h:29,
from src\arpackobject.c:24:
src\graphobject.h:42: error: syntax error before "igraph_t"
src\graphobject.h:42: warning: no semicolon at end of struct or union
src\graphobject.h:44: error: 'destructor' redeclared as different kind of symbol C:/Python32/include/object.h:277: error: previous declaration of 'destructor' was here src\graphobject.h:51: error: syntax error before '}' token
src\graphobject.h:51: warning: type defaults to `int' in declaration of `igraphmodule_GraphObject' src\graphobject.h:51: warning: data definition has no type or storage class
src\graphobject.h:53: error: syntax error before '*' token
src\graphobject.h:55: error: syntax error before '*' token src\graphobject.h:56: error: syntax error before '*' token src\graphobject.h:57: error: syntax error before '*' token src\graphobject.h:58: error: syntax error before '*' token src\graphobject.h:59: error: syntax error before '*' token src\graphobject.h:60: error: syntax error before '*' token src\graphobject.h:62: error: syntax error before '*' token src\graphobject.h:63: error: syntax error before '*' token src\graphobject.h:64: error: syntax error before '*' token src\graphobject.h:65: error: syntax error before '*' token src\graphobject.h:66: error: syntax error before '*' token src\graphobject.h:67: error: syntax error before '*' token src\graphobject.h:68: error: syntax error before '*' token src\graphobject.h:69: error: syntax error before '*' token src\graphobject.h:70: error: syntax error before '*' token src\graphobject.h:71: error: syntax error before '*' token src\graphobject.h:72: error: syntax error before '*' token src\graphobject.h:73: error: syntax error before '*' token src\graphobject.h:74: error: syntax error before '*' token src\graphobject.h:75: error: syntax error before '*' token src\graphobject.h:76: error: syntax error before '*' token src\graphobject.h:77: error: syntax error before '*' token src\graphobject.h:102: error: syntax error before '*' token src\graphobject.h:103: error: syntax error before '*' token src\graphobject.h:104: error: syntax error before '*' token src\graphobject.h:105: error: syntax error before '*' token src\graphobject.h:106: error: syntax error before '*' token src\graphobject.h:107: error: syntax error before '*' token src\graphobject.h:108: error: syntax error before '*' token src\graphobject.h:109: error: syntax error before '*' token src\graphobject.h:110: error: syntax error before '*' token src\graphobject.h:111: error: syntax error before '*' token src\graphobject.h:112: error: syntax error before '*' token src\graphobject.h:113: error: syntax error before '*' token src\graphobject.h:114: error: syntax error before '*' token src\graphobject.h:115: error: syntax error before '*' token src\graphobject.h:116: error: syntax error before '*' token src\graphobject.h:117: error: syntax error before '*' token src\graphobject.h:118: error: syntax error before '*' token src\graphobject.h:119: error: syntax error before '*' token src\graphobject.h:120: error: syntax error before '*' token src\graphobject.h:121: error: syntax error before '*' token src\graphobject.h:122: error: syntax error before '*' token src\graphobject.h:123: error: syntax error before '*' token src\graphobject.h:124: error: syntax error before '*' token src\graphobject.h:125: error: syntax error before '*' token src\graphobject.h:126: error: syntax error before '*' token src\graphobject.h:127: error: syntax error before '*' token src\graphobject.h:128: error: syntax error before '*' token src\graphobject.h:129: error: syntax error before '*' token src\graphobject.h:130: error: syntax error before '*' token src\graphobject.h:132: error: syntax error before '*' token src\graphobject.h:133: error: syntax error before '*' token src\graphobject.h:134: error: syntax error before '*' token src\graphobject.h:135: error: syntax error before '*' token src\graphobject.h:136: error: syntax error before '*' token src\graphobject.h:137: error: syntax error before '*' token src\graphobject.h:138: error: syntax error before '*' token src\graphobject.h:139: error: syntax error before '*' token src\graphobject.h:140: error: syntax error before '*' token src\graphobject.h:141: error: syntax error before '*' token src\graphobject.h:142: error: syntax error before '*' token src\graphobject.h:143: error: syntax error before '*' token src\graphobject.h:145: error: syntax error before '*' token src\graphobject.h:146: error: syntax error before '*' token src\graphobject.h:147: error: syntax error before '*' token src\graphobject.h:148: error: syntax error before '*' token src\graphobject.h:150: error: syntax error before '*' token src\graphobject.h:159: error: syntax error before '*' token src\graphobject.h:160: error: syntax error before '*' token src\graphobject.h:161: error: syntax error before '*' token src\graphobject.h:162: error: syntax error before '*' token src\graphobject.h:163: error: syntax error before '*' token src\graphobject.h:164: error: syntax error before '*' token src\graphobject.h:165: error: syntax error before '*' token src\graphobject.h:167: error: syntax error before '*' token src\graphobject.h:168: error: syntax error before '*' token src\graphobject.h:169: error: syntax error before '*' token src\graphobject.h:170: error: syntax error before '*' token src\graphobject.h:171: error: syntax error before '*' token src\graphobject.h:172: error: syntax error before '*' token src\graphobject.h:173: error: syntax error before '*' token src\graphobject.h:175: error: syntax error before '*' token src\graphobject.h:176: error: syntax error before '*' token src\graphobject.h:177: error: syntax error before '*' token src\graphobject.h:178: error: syntax error before '*' token src\graphobject.h:179: error: syntax error before '*' token src\graphobject.h:180: error: syntax error before '*' token src\graphobject.h:182: error: syntax error before '*' token src\graphobject.h:183: error: syntax error before '*' token src\graphobject.h:185: error: syntax error before '*' token src\graphobject.h:186: error: syntax error before '*' token src\graphobject.h:187: error: syntax error before '*' token src\graphobject.h:188: error: syntax error before '*' token src\graphobject.h:189: error: syntax error before '*' token src\graphobject.h:190: error: syntax error before '*' token src\graphobject.h:191: error: syntax error before '*' token src\graphobject.h:193: error: syntax error before '*' token src\graphobject.h:194: error: syntax error before '*' token src\graphobject.h:196: error: syntax error before '*' token src\graphobject.h:197: error: syntax error before '*' token src\graphobject.h:198: error: syntax error before '*' token src\graphobject.h:199: error: syntax error before '*' token src\graphobject.h:201: error: syntax error before '*' token src\graphobject.h:202: error: syntax error before '*' token src\graphobject.h:203: error: syntax error before '*' token src\graphobject.h:204: error: syntax error before '*' token src\graphobject.h:205: error: syntax error before '*' token src\graphobject.h:206: error: syntax error before '*' token src\graphobject.h:207: error: syntax error before '*' token src\graphobject.h:208: error: syntax error before '*' token src\graphobject.h:210: error: syntax error before '*' token src\graphobject.h:211: error: syntax error before '*' token src\graphobject.h:212: error: syntax error before '*' token src\graphobject.h:213: error: syntax error before '*' token src\graphobject.h:214: error: syntax error before '*' token src\graphobject.h:215: error: syntax error before '*' token src\graphobject.h:216: error: syntax error before '*' token src\graphobject.h:217: error: syntax error before '*' token src\graphobject.h:218: error: syntax error before '*' token src\graphobject.h:219: error: syntax error before '*' token src\graphobject.h:220: error: syntax error before '*' token src\graphobject.h:222: error: syntax error before '*' token src\graphobject.h:224: error: syntax error before '*' token src\graphobject.h:225: error: syntax error before '*' token In file included from src\arpackobject.c:24: src\arpackobject.h:43: error: syntax error before "igraph_arpack_options_t" src\arpackobject.h:43: warning: no semicolon at end of struct or union src\arpackobject.h:44: warning: type defaults to `int' in declaration of `params_out' src\arpackobject.h:44: warning: data definition has no type or storage class src\arpackobject.h:45: warning: type defaults to `int' in declaration of `igraphmodule_ARPACKOptionsObject' src\arpackobject.h:45: warning: data definition has no type or storage class src\arpackobject.h:49: error: syntax error before '*' token src\arpackobject.h:52: error: syntax error before '*' token src\arpackobject.h:54: error: syntax error before '*' token src\arpackobject.h:54: error: syntax error before '*' token src\arpackobject.h:54: warning: type defaults to `int' in declaration of `igraphmodule_ARPACKOptions_get' src\arpackobject.h:54: warning: data definition has no type or storage class In file included from src\arpackobject.c:26: src\error.h:28:26: igraph_error.h: No such file or directory src\arpackobject.c: In function `igraphmodule_ARPACKOptions_new': src\arpackobject.c:45: error: `self' undeclared (first use in this function) src\arpackobject.c:45: error: (Each undeclared identifier is reported only once src\arpackobject.c:45: error: for each function it appears in.) src\arpackobject.c:46: error: syntax error before ')' token src\arpackobject.c:49: warning: implicit declaration of function `igraph_arpack_options_init' src\arpackobject.c: At top level: src\arpackobject.c:60: error: syntax error before '*' token src\arpackobject.c: In function `igraphmodule_ARPACKOptions_dealloc': src\arpackobject.c:62: error: `self' undeclared (first use in this function) src\arpackobject.c: At top level: src\arpackobject.c:69: error: syntax error before '*' token src\arpackobject.c: In function `igraphmodule_ARPACKOptions_getattr': src\arpackobject.c:72: error: `attrname' undeclared (first use in this function) src\arpackobject.c:73: error: `self' undeclared (first use in this function) src\arpackobject.c: At top level: src\arpackobject.c:123: error: syntax error before '*' token src\arpackobject.c: In function `igraphmodule_ARPACKOptions_setattr': src\arpackobject.c:125: error: `value' undeclared (first use in this function) src\arpackobject.c:129: error: `attrname' undeclared (first use in this function) src\arpackobject.c:133: error: `self' undeclared (first use in this function) src\arpackobject.c:144: error: `igraph_real_t' undeclared (first use in this function) src\arpackobject.c:144: error: syntax error before "PyLong_AsLong" src\arpackobject.c:146: error: syntax error before "PyFloat_AsDouble" src\arpackobject.c: At top level: src\arpackobject.c:160: error: syntax error before '*' token src\arpackobject.c:161: error: syntax error before '*' token src\arpackobject.c:161: warning: return type defaults to `int' src\arpackobject.c: In function `igraphmodule_ARPACKOptions_get': src\arpackobject.c:162: error: `self' undeclared (first use in this function) src\arpackobject.c: At top level: src\arpackobject.c:180: error: syntax error before '*' token src\arpackobject.c:220: error: initializer element is not constant src\arpackobject.c:220: error: (near initialization for `igraphmodule_ARPACKOptionsType.tp_dealloc') src\arpackobject.c:220: error: syntax error before "igraphmodule_ARPACKOptions_dealloc" error: command 'gcc' failed with exit status 1

I have tried a bunch of things that I am not even going to list here. Any help would be greatly appreciated!

Thanks.

Question information

Language:
English Edit question
Status:
Solved
For:
igraph Edit question
Assignee:
Tamás Nepusz Edit question
Solved by:
Nybi Clamence
Solved:
Last query:
Last reply:
Revision history for this message
Tamás Nepusz (ntamas) said :
#1

Have you compiled the C core of the igraph library? Note that the tarball you can download for the Python interface is really just an _interface_ (i.e. glue code) between the C core of igraph and the Python interpreter, so in order to compile it, you have to compile the C core of igraph first.

Revision history for this message
Nybi Clamence (nybi) said :
#2

I actually haven't compiled the C core (or at least not that I know of) and I can't find any information on it. Could you possibly supply some kind of guideline?
Thanks again.

Revision history for this message
Tamás Nepusz (ntamas) said :
#3

Hang on, I'm currently struggling with the compilation of igraph and the Python interface under Windows (we haven't tried it for a while and we don't test igraph regularly under Windows). I'll get back to you when I managed to compile it; I'll also try to create a workable installer for Python 3.2 so you don't have to compile it yourself.

Revision history for this message
Nybi Clamence (nybi) said :
#4

Oh that'd be great! Thanks so much. Let me know when it's working and I'll put the problem as solved.

Revision history for this message
Tamás Nepusz (ntamas) said :
#5

I have prepared an experimental installer for Python 3.2 and uploaded it to the following URL:

http://dl.dropbox.com/u/1911856/python-igraph-0.6.win32-py3.2.msi

Please try it and let me know whether it works for you. It works for me in a virtual machine, apart from two test case failures, one in the DIMACS reader and one in the eigenvector calculations (which occurs only for specific small graphs with less than five vertices).

Revision history for this message
Nybi Clamence (nybi) said :
#6

The installation went fine. I ran it from my desktop and it copied three folders on the desktop: Scripts, Lib, Include.

However, "import igraph" returns "No module named igraph". Should I move the three folders to a specific location?

Also note that I am running Windows 7 (64bit).

Thanks.

Revision history for this message
Tamás Nepusz (ntamas) said :
#7

Oh, that's bad because the installer was compiled on a 32bit Windows system and I don't have access to a 64-bit system. Since it couldn't find a 32-bit version of Python, it just dumped the folders on the desktop. Can you install a 32-bit Python, or are you willing to try compiling everything from scratch using Microsoft Visual Studio? (VC Express 2008 should be fine).

Revision history for this message
Nybi Clamence (nybi) said :
#8

I'd be more than happy to compile it from scratch with some guideline since I've already installed Microsoft Visual Studio.

Revision history for this message
Tamás Nepusz (ntamas) said :
#9

First, please download the following ZIP:

http://dl.dropbox.com/u/1911856/igraph-0.6-msvc.zip

This contains the C core of igraph as a Microsoft Visual Studio project. Open it in VC Express and try to build the whole solution in release mode. I'll get back to you tomorrow with the rest of the instructions. Note that you will need the latest nightly snapshot of the Python interface (which will be uploaded in a few hours) because I had to make some modifications today to make it compile with Python 3.2. So, anyway, please try to compile the Visual Studio project in the above ZIP file and we continue from here tomorrow.

Revision history for this message
Nybi Clamence (nybi) said :
#10

I built the whole solution, which created new files in the folder where I extracted zip file. I will wait for the latest nightly snapshot and for your instructions.
Thanks.

Revision history for this message
Nybi Clamence (nybi) said :
#11

I downloaded and unzipped the latest nightly snapshot.

Revision history for this message
Tamás Nepusz (ntamas) said :
#12

I'm back; sorry, haven't been online the whole day. So, please do the following:

1. Extract the source code of the latest nightly snapshot of the Python interface.

2. Remove setup.cfg (if there is any).

3. Re-create setup.cfg with the following contents:

[build_ext]
include_dirs=C:\folder-where-you-have-extracted-igraph\include
library_dirs=C:\folder-where-you-have-extracted-igraph\Release

4. Run "python setup.py build bdist_msi" from the folder of the Python interface. The installer should have been created in the dist subfolder.

5. Run the installer, then launch Python 3.2, and type "import igraph"

Revision history for this message
Tamás Nepusz (ntamas) said :
#13

I forgot to mention that the above will work only if the C compiler of Visual Studio (cl.exe) is set up to be on your PATH. My VC installation gave me a separate menu item in the Start menu (on Windows XP) which lets me open a command line window where the PATH is set up appropriately.

Revision history for this message
Nybi Clamence (nybi) said :
#14

Tamas,

Thanks for the update. I changed the setup.cfg file (using Notepad) to exactly:
"
[build_ext]
include_dirs=C:\folder-where-you-have-extracted-igraph\include
library_dirs=C:\folder-where-you-have-extracted-igraph\Release
"
obviously substituting "folder-where-you-have-extracted-igraph" with the actual folder.

But when running the code (though Visual Studio command line window), I get"

Using default include and library paths for compilation
If the compilation fails, please edit the LIBIGRAPH_FALLBACK_*
variables in setup.py or include_dirs and library_dirs in
setup.cfg to point to the correct directories and libraries
where the C core of igraph is installed

Include path: /usr/include /usr/local/include
Library path:
C:\Python32\lib\distutils\dist.py:257: UserWarning: Unknown distribution option:
  'test_suite'
  warnings.warn(msg)
running build
running build_py
running build_ext
building 'igraph._igraph' extension
C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -I/usr/include -I/usr/local/include -IC:\Users\SMART\Desktop\igraph-0.6-msvc\igraph-0.6-msvc\include -IC:\Python32\include -IC:\Python32\PC /Tcsrc\arpackobject.c /Fobuild\temp.win-amd64-3.2\Release\src\arpackobject.obj

arpackobject.c
 c:\python32\include\pyconfig.h(223) : fatal error C1083: Cannot open include file: 'basetsd.h': No such file or directory error: command '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2

Any idea what the problem could be?

Revision history for this message
Tamás Nepusz (ntamas) said :
#15

This is probably a problem with your Visual Studio setup; on my system, the missing file (basetsd.h) is to be found here:

C:\Program Files\Microsoft SDKs\Windows\v6.0A\Include

I think it is part of the Windows SDK so you can probably get it here:
http://www.microsoft.com/en-us/download/details.aspx?id=3138

By the way, I'm slightly worried by the fact that the output above says "C:\Program Files (x86)" and not "C:\Program Files"; this seems to indicate that Visual Studio is 32-bit and not 64-bit, so the igraph core you compiled with it and the Python interface you are about to compile might also be compiled for 32-bit. Have you tried downloading the 32-bit version of Python 3.2 and using my pre-compiled igraph installer with that?

Revision history for this message
Nybi Clamence (nybi) said :
#16

The installation of the 32-bit version of Python 3.2 wants to overwrite the current python files. Is that ok?

Otherwise, I am currently "repairing" my installation of Windows SDK (and it is taking a bit of time).

Finally, I tried using MinGW instead, using the same procedure as above:
- set PATH=C:\MinGW\bin;%PATH%
- setup.py build -c mingw32 install

which actually runs for quite a while, giving me many "undefined references". The last part of the log says:
C:\~\igraph-0.6-msvc\Release/igraph.lib(./Release/endfile.obj):(.text+0xe5): undefined reference to `@__security_check_cookie@4'
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

Any thoughts?

Revision history for this message
Nybi Clamence (nybi) said :
#17

Repairing Windows SDK did not change a thing. I still get the same error message. Would the person hosting http://www.lfd.uci.edu/~gohlke/pythonlibs/ know?

No luck with MinGW either.

Revision history for this message
Tamás Nepusz (ntamas) said :
#18

Don't try it with MinGW, chances are that it won't work, partly because the C core of igraph has not been compiled with MinGW, and partly because Python itself is not compiled with MinGW.

I guess it's fine to overwrite the files of the 64-bit Python unless you have some packages in your 64-bit installation that you know not to work with the 32-bit version.

Revision history for this message
Nybi Clamence (nybi) said :
#19

I have cleanly uninstalled python 3.2 64-bit and installed the 32-bit version. I then installed igraph 0.6, which went smoothly, and import igraph seems to work fine.

Now I am trying to run some tests (bearing in mind I have never used igraph, and so I don't know how it works). I opened the basic.py test from the test folder of igraph, and running it gives me:
"
...............
----------------------------------------------------------------------
Ran 15 tests in 0.024s

OK
"

Am I not supposed to see a graph somewhere?
Thanks.

Revision history for this message
Tamás Nepusz (ntamas) said :
#20

Nope, you are not supposed to see anything apart from "OK". You can run the entire test suite from the command line as follows:

python -m igraph.test.__init__

I think one or two test cases will fail (as mentioned in #5), but neither of these affect everyday use of igraph.

Revision history for this message
Nybi Clamence (nybi) said :
#21

Yes! All good! I only got one error.
Thanks a lot!