问题
I am trying to install pygraphviz on Mac OS 10.7.5 running Anaconda Python. In the last installation step, I get this error:
$ sudo python setup.py install
library_path=/usr/local/lib/graphviz
include_path=/usr/local/include/graphviz
running install
running build
running build_py
running build_ext
building 'pygraphviz._graphviz' extension
/usr/bin/clang -fno-strict-aliasing -I/Users/user2490492/anaconda/include
-arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk -DNDEBUG
-g -fwrapv -O3 -Wall -Wstrict-prototypes -I/usr/local/include/graphviz -
I/Users/user2490492/anaconda/include/python2.7
-c pygraphviz/graphviz_wrap.c
-o build/temp.macosx-10.5-x86_64-2.7/pygraphviz/graphviz_wrap.o
In file included from pygraphviz/graphviz_wrap.c:124:
/Users/user2490492/anaconda/include/python2.7/Python.h:33:10:
fatal error: 'stdio.h' file not found
#include <stdio.h>
^
1 error generated.
error: command '/usr/bin/clang' failed with exit status 1
My initial troubleshooting from a host of related questions led me to these actions:
- Check the Python version:
$ python --version
gives mePython 2.7.5 :: Anaconda 1.5.1 (x86_64)
- Check that Graphviz is installed: done! I can run
graphviz
both as a standalone application and from the command line. For instance:$ which neato
gives me/usr/local/bin/neato
. - Update the library_path and include_path in setup.py: done! (See the error report above -- both of these paths are valid on my system)
- Install XCode 4 and install command line tools: done!
$ xcode-select -version
gives mexcode-select version 2308.
- Export ARCHFLAGS: done! This was done in what I call incantation mode -- I have no idea what it was supposed to do, just that it seemed to help another user. I used this:
export ARCHFLAGS='-arch i386 -arch x86_64'
before runningsudo python setup.py install
again. - Switch XCode: Also in incantation mode I vainly tried:
sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/
. I got this from another SO answer but have lost the link, sorry...
Apart from switching away from OS X, is there anything else I should do? (Also tagging this as networkx
-related since that package also uses pygraphviz
).
来源:https://stackoverflow.com/questions/17132364/installing-pygraphviz-on-os-x-10-7-5