2012-06-26 44 views
3

我每次尝试安装pygit2时都会遇到奇怪的问题。以下是我运行和产生的错误。为什么我错过了git2.h,我该如何恢复?

$ python3 setup.py install 
running install 
running build 
running build_py 
running build_ext 
building '_pygit2' extension 
/usr/bin/clang -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -Os -w -pipe -march=native -Qunused-arguments -mmacosx-version-min=10.7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk -isystem /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/lib -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.7.sdk/usr/include -I/usr/local/include -Iinclude -I/usr/local/Cellar/python3/3.2.3/include/python3.2m -c src/pygit2.c -o build/temp.macosx-10.7-x86_64-3.2/src/pygit2.o 
In file included from src/pygit2.c:32: 
include/pygit2/error.h:6:10: fatal error: 'git2.h' file not found 
#include <git2.h> 
     ^
1 error generated. 
error: command '/usr/bin/clang' failed with exit status 1 

我想我已经成功安装了libgit2(构建和制作完成)。也许这是一个路径问题?我已将LIBGIT2环境变量设置为libgit2文件夹中的src目录。这是正确的地方吗?

回答

2

我从来没有安装libgit2,但下面可能会有帮助:

如果你的发行版的存储库包含libgit2,我会建议,删除你以前编译和安装libgit2(二进制)和libgit2-DEV(头等等)从回购包。这将把二进制文件和源文件放到正确的目录中。

否则,尝试符号链接git2.h/usr/local/include

+0

另外,看看这里: https://github.com/libgit2/objective-git/issues/60 – dmytro

2

它看起来并不像LIBGIT2变了(你能告诉你如何设置的变量?)作为额外的包括指令使用/usr/local/include(这是默认值)。

LIBGIT2 env var需要设置为安装库的前缀,通常为/usr/usr/local。由于编译器无法找到它,所以看起来库看起来并没有安装到/usr/local,所以在运行setup.py之前,可能需要export LIBGIT2=/usr