0

I've made the debatable decision to do some network analysis directly in Python instead of R. However, I'm having trouble getting all the igraph dependencies installed, ultimately failing with py2cairo.

After updating Xcode to latest, installed cairo with Homebrew:

brew install cairo

A few warnings there for dependent libraries, and the brew link step failed. After chowning a few directories, I ran brew link again and it worked.

Then, I uninstalled and re-installed python-igraph using pip.

Now I need to install py2cairo from source (I'm running Python 2.7.6 in a virtualenv) and so downloaded it from this source:

git clone git://git.cairographics.org/git/py2cairo

Following Install pycairo in virtualenv, I ran ./waf configure --prefix=$VIRTUAL_ENV with no problems.

Running ./waf build falls over with these errors:

ld: warning: ignoring file /usr/local/Cellar/cairo/1.14.2_1/lib/libcairo.dylib, file was built for x86_64 which is not the architecture being linked (i386): /usr/local/Cellar/cairo/1.14.2_1/lib/libcairo.dylib
[...]
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

I then tried to switch to using autogen.sh. First problem was that pkg.m4 was missing on my machine, so I tried reinstalling pkg-config with Homebrew again. Didn't work. So I downloaded pkg.m4 from here http://web.mit.edu/barnowl/src/pkg-config/pkg-config-0.23/pkg.m4, then installed libtools with Homebrew, and changed references in autogen to glibtoolize etc.

But then autogen.sh terminates with following errors:

autogen.sh: running `aclocal'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/m4:/usr/local/Cellar/automake/1.15/share/aclocal/pkg.m4:155: ERROR: end of file in comment
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: error: echo failed with exit status: 1
Community
  • 1
  • 1
tchaymore
  • 3,728
  • 13
  • 55
  • 86
  • 1
    You are probably running a Python built for the `i386` architecture in your `virtualenv`, but the version of Cairo that you have installed from Homebrew is for `x86_64`. Can you try it with a different version of Python that is built for `x86_64`? – Tamás Aug 03 '15 at 09:43
  • When I run `platform.architecture()` I get `('64bit','') and sys.maxsize is 9223372036854775807. Might I still be running in 32bit mode somehow? – tchaymore Aug 04 '15 at 03:18
  • 1
    Probably not, but still the error message that `ld` printed after you ran `waf build` explicitly states that you are linking something for the `i386` architecture (i.e. 32-bit) while `libcairo.dylib` provides 64-bit architecture code only. It *could* be the case that `waf` is trying to build a "universal" library (containing 32-bit and 64-bit code as well). I would try `brew uninstall cairo && brew install cairo --universal` - this should build Cairo for 32-bit and 64-bit archs as well so you could then link to it from `waf build`. – Tamás Aug 04 '15 at 21:37
  • 1
    System Python is a universal build, as Tamás alludes. Using a universal cairo, like he suggests, or a thin python (like Homebrew's) should help. You can also install py2cairo with brew and then create your virtualenv with --system-site-packages. – Tim Smith Aug 06 '15 at 06:54

1 Answers1

0

export ARCHFLAGS='-arch x86_64' # this is for Mac os x ./waf clean ./waf configure --prefix=`python -c "import sys; print sys.prefix"` ./waf build ./waf install

This works well on my Mac

timesking
  • 275
  • 1
  • 3
  • 11