Python 为什么我错过了git2.h,我如何找回它?

Python 为什么我错过了git2.h,我如何找回它?,python,c,git,linker,libgit2,Python,C,Git,Linker,Libgit2,每次尝试设置pygit2时,我都会遇到一个奇怪的问题。下面是我运行的程序和生成的错误 $ 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=n

每次尝试设置pygit2时,我都会遇到一个奇怪的问题。下面是我运行的程序和生成的错误

$ 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
$python3 setup.py安装
正在运行的安装
运行构建
运行build\u py
运行build_ext
构建“\u pygit2”扩展
/usr/bin/clang-DNDEBUG-g-fwrapv-O3-Wall-Wstrict原型-Os-w-pipe-march=native-qused参数-mmacoxx版本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/Xcode.app/Contents/MacOSX.Platforms/Developer/Platforms/Developer/Platforms/MacOSX.7.sdk/usr/lib-I/Applications/Xcode.app/Contents/Contents/Developer/MacOSX10.7.sdk/usr/include-I/usr/local/include-Iinclude-I/usr/local/cillar/python3/3.2.3/include/python3.2m-c src/pygit2.c-o build/temp.macosx-10.7-x86_64-3.2/src/pygit2.o
在src/pygit2.c中包含的文件中:32:
include/pygit2/error.h:6:10:致命错误:“未找到git2.h”文件
#包括
^
生成1个错误。
错误:命令“/usr/bin/clang”失败,退出状态为1

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

我从未安装过
libgit2
,但以下内容可能会有所帮助:

如果您的发行版的存储库包含libgit2,我建议您删除之前编译的内容,并从repo中安装libgit2(二进制文件)和libgit2 dev(头文件等)包。这将把二进制文件和源文件放到正确的目录中


否则,请尝试将
git2.h
符号链接到
/usr/local/include
,它看起来不像
LIBGIT2
变量(可以显示如何设置变量吗?),因为额外的include指令使用
/usr/local/include
(这是默认值)

LIBGIT2
env变量需要设置为安装库的前缀,通常是
/usr
/usr/local
。由于编译器找不到该库,因此看起来该库没有安装到
/usr/local
,因此在运行
setup.py
之前,可能需要导出LIBGIT2=/usr