我正在编写python程序来处理git存储库,它可以在win7上工作,但我也需要这个程序在win xp上工作(win xp支持python3.4,pygit2 0.28不适用于win xp (dll导入错误),所以我安装了pygit2 0.25.0),我正在使用pygit2构建.exe。
p = pygit2.Repository(repository_path) 生成异常(在windows上):
未能解决路径'C:\TestRepository.git‘:无效参数
def get_repo():
repository_path = "C:\\TestRepository\\.git"
try:
p = pygit2.Repository(repository_path)
except Exception as e:
print(str(e) + " (exception)") # print to console
return None
return p我试过的是:
repository_path = Path("C:\\TestRepository\\.git").resolve() 返回异常:必须是str,而不是windows路径
repository_path = "C:/TestRepository/.git"
repository_path = b"C:\\TestRepository\\.git"
repository_path = r"C:\TestRepository\.git"
repository_path = "C:\\TestRepository\\.git".encode("utf-8")返回异常:未能解析路径'C:\TestRepository.git‘:无效参数
我期望函数get_repo返回存储库
发布于 2019-07-22 08:39:33
解决方案: libgit2从0.21.0版本中取消了对Windows的支持
https://stackoverflow.com/questions/57106535
复制相似问题