Python安裝pygit2失敗問(wèn)題及解決
Python安裝pygit2失敗
報(bào)錯(cuò)輸出
這是最后一部分輸出
In file included from src/blob.c:30:0:
src/blob.h:33:10: fatal error: git2.h: 沒(méi)有那個(gè)文件或目錄
#include <git2.h>
^~~~~~~~
compilation terminated.
error: command 'gcc' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for pygit2
Failed to build pygit2
ERROR: Could not build wheels for pygit2 which use PEP 517 and cannot be installed directly
原因
我是因?yàn)镻ython的版本太低了。
現(xiàn)在是3.6,我更新到3.9后就好了。更新命令
conda update python
python調(diào)用gitpython,遇到gitpython庫(kù)不支持的復(fù)雜命令或個(gè)性命令時(shí)的解決
需求
在執(zhí)行g(shù)it log命令時(shí),git中支持諸如:
git log --pretty=format:"%H,%an,%cd" “D:\your_target_file_path”> D:/test/log_data/log.csv
但是當(dāng)我們希望通過(guò)python批量拉取自定義repo的時(shí)候
我們發(fā)現(xiàn)gitpython時(shí),并不支持這類非常規(guī)命令(如果有知道如何使用非常規(guī)命令的小伙伴在評(píng)論區(qū)指出)
這個(gè)時(shí)候我們可以通過(guò)python+cmd的思路來(lái)解決這個(gè)問(wèn)題
Git_Log.py
import subprocess # microsoftdocs/azure-docs-sdk-python RepoFullName = input(str("請(qǐng)輸入Repo:")) RepoFullName_split = RepoFullName.split("/") repo_file = RepoFullName_split[0]+"_"+RepoFullName_split[1] cmd1 = "cd \\" cmd2 = "D:" cmd3 = "cd test" cmd5 = "cd {}".format(repo_file) cmd6 = "git init" cmd8 = "git checkout -b baymax_branch" cmd14 = """git log --pretty=format:"%H,%an,%cd" > D:/test/log_data/log_{}.csv""".format(repo_file) cmd = cmd1 + " && " + cmd2 + " && " + cmd3 + " && " + \ cmd5 + " && " + cmd6 + " && " + cmd8 + " && " + cmd14 subprocess.Popen(cmd, shell=True)
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Python中字符串相關(guān)操作的運(yùn)算符總結(jié)
這篇文章主要介紹了Python之字符串相關(guān)操作的運(yùn)算符,本文通過(guò)案例給大家詳細(xì)講解python字符串運(yùn)算符的說(shuō)明,需要的朋友可以參考下2023-12-12Python?的?ultralytics?庫(kù)功能及安裝方法
ultralytics庫(kù)由Ultralytics團(tuán)隊(duì)開發(fā),旨在為YOLO系列模型提供高效、靈活且易于使用的工具,本文將詳細(xì)介紹ultralytics庫(kù)的功能、安裝方法、核心模塊以及使用示例,感興趣的朋友一起看看吧2025-03-03淺析Python 中的 WSGI 接口和 WSGI 服務(wù)的運(yùn)行
這篇文章主要介紹了Python 中的 WSGI 接口和 WSGI 服務(wù)的相關(guān)資料,幫助大家更好的理解和使用python,感興趣的朋友可以了解下2020-12-12Opencv常見(jiàn)圖像格式Data Type及代碼實(shí)例
這篇文章主要介紹了Opencv常見(jiàn)圖像格式Data Type及代碼實(shí)例,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-11-11python+tkinter編寫電腦桌面放大鏡程序?qū)嵗a
這篇文章主要介紹了Python+tkinter編寫電腦桌面放大鏡程序?qū)嵗a,具有一定借鑒價(jià)值,需要的朋友可以參考下2018-01-01python關(guān)于excel多個(gè)sheet的導(dǎo)入導(dǎo)出方式
這篇文章主要介紹了python關(guān)于excel多個(gè)sheet的導(dǎo)入導(dǎo)出方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2022-12-12pytorch MSELoss計(jì)算平均的實(shí)現(xiàn)方法
這篇文章主要介紹了pytorch MSELoss計(jì)算平均的實(shí)現(xiàn)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2021-05-05