python解決報錯ImportError: Bad git executable.問題
python報錯ImportError: Bad git executable.
在跑代碼時出現(xiàn)了以下錯誤:
Bad git executable.
按照上述路徑,找到E:\Anaconda3\Lib\site-packages\git\cmd
添加:
os.environ['GIT_PYTHON_REFRESH'] = 'quiet'
問題解決
python使用gitPython時報錯git.exc.GitCommandNotFound的解決
官方的解釋
git.exc.GitCommandNotFound(命令,原因)
如果在PATH或GIT_PYTHON_GIT_EXECUTABLE環(huán)境變量給定的路徑中找不到git可執(zhí)行文件,則拋出該異常
? ? def git_cmd(self, working_dir, command): ? ? ? ? """執(zhí)行g(shù)it cmd命令""" ? ? ? ? exec_res = Git(working_dir).execute(command=command) ? ? ? ? return exec_res
報錯定位到在執(zhí)行execute()方法是報錯
查看git.cmd.Git(working_dir =無).execute()的官方文檔
execute(命令,istream = None,with_extended_output = False,with_exceptions = True,as_process = False,output_stream = None,stdout_as_string = True,kill_after_timeout = None,with_stdout = True,Universal_newlines = False,shell = None,env = None,max_chunk_size = 8192,** subprocess_kwargs )
處理在Shell上執(zhí)行命令并使用并返回返回的信息(stdout)
參數(shù):
- command –要執(zhí)行的命令參數(shù)列表。它應(yīng)該是一個字符串或一系列程序參數(shù)。要執(zhí)行的程序是args序列或字符串中的第一項。
- shell –是否通過shell調(diào)用命令(請參閱Popen(…,shell = True))。
- USE_SHELL如果不是None,它將覆蓋。
exec_res = Git(working_dir).execute(command=command, shell=True)
加上“shell=True"后就可以執(zhí)行成功了
總結(jié)
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
- 解決python報錯ImportError:urllib3?v2.0?only?supports?OpenSSL?1.1.1+
- Python報錯ImportError:?IProgress?not?found.?Please?update?jupyter?and?ipywidgets解決
- python項目導(dǎo)入open3d后報錯ImportError:DLL load failed:找不到指定的模塊問題
- Python報錯ImportError: No module named ‘missing_module‘的解決方法
- Python 報錯ImportError: No module named ***的問題解決
相關(guān)文章
python3實現(xiàn)二叉樹的遍歷與遞歸算法解析(小結(jié))
這篇文章主要介紹了python3實現(xiàn)二叉樹的遍歷與遞歸算法解析(小結(jié)),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-07-07python使用Tkinter顯示網(wǎng)絡(luò)圖片的方法
這篇文章主要介紹了python使用Tkinter顯示網(wǎng)絡(luò)圖片的方法,涉及Python操作圖片的相關(guān)技巧,需要的朋友可以參考下2015-04-04跟老齊學(xué)Python之集成開發(fā)環(huán)境(IDE)
IDE的全稱是:Integrated Development Environment,簡稱IDE,也稱為Integration Design Environment、Integration Debugging Environment,翻譯成中文叫做“集成開發(fā)環(huán)境”,在臺灣那邊叫做“整合開發(fā)環(huán)境”。2014-09-09