python - 为什么我缺少 git2.h 以及如何取回它?

标签 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=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 目录。那是正确的地方吗?

最佳答案

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

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

否则,尝试将 git2.h 符号链接(symbolic link)到 /usr/local/include

关于python - 为什么我缺少 git2.h 以及如何取回它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11216922/

相关文章:

c - 计算点与多个面之间最小距离的有效方法

c - 处理导致段错误的空字符串输入

python - 如何生成所有整数 i, n & i == n (保持位长)

python - scypy python 模块中的 odeint() 如何工作?

Python Pandas - 循环遍历 Excel 文件的文件夹,将每个 Excel 文件的工作表中的数据导出到各自的 .xlsx 文件中

git - 如何使用 GitHub 的 API 从差异或补丁创建提交?

git - 如何在 Gitolite 配置中为存储库添加描述

python - 使用 CDK 和 Python 创建实例配置文件

c - 在 Linux C 程序中的非特权套接字(非原始套接字)上设置 TCP 选项

linux - GIT 停止复制所有者和组权限