Win10+python3.6+git運(yùn)行出現(xiàn)問題的解決
Win10+python3.6+git運(yùn)行出現(xiàn)問題
問題描述
這個(gè)問題有點(diǎn)迷,基本就是因?yàn)閜ython無法調(diào)用git, 很可能是環(huán)境變量的問題, 設(shè)置了一下,還是不行
如下了下面的錯(cuò)誤提示:
ImportError: Bad git executable.
The git executable must be specified in one of the following ways:
- be included in your $PATH
- be set via $GIT_PYTHON_GIT_EXECUTABLE
- explicitly set via git.refresh()All git commands will error until this is rectified.
This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
- quiet|q|silence|s|none|n|0: for no warning or exception
- warn|w|warning|1: for a printed warning
- error|e|raise|r|2: for a raised exceptionExample:
export GIT_PYTHON_REFRESH=quiet
During handling of the above exception, another exception occurred:
解決方案
很簡單。。。
在小黑窗中輸入下面的指令即可:
set GIT_PYTHON_GIT_EXECUTABLE=C:\Program Files\Git\cmd\git.exe
應(yīng)該就是手動(dòng)設(shè)置環(huán)境變量,可以使得python調(diào)用git。
ImportError: Bad git executable錯(cuò)誤的解決
錯(cuò)誤具體形式如下:
ImportError: Failed to initialize: Bad git executable.
The git executable must be specified in one of the following ways:
- be included in your $PATH
- be set via $GIT_PYTHON_GIT_EXECUTABLE
- explicitly set via git.refresh()All git commands will error until this is rectified.
This initial warning can be silenced or aggravated in the future by setting the
$GIT_PYTHON_REFRESH environment variable. Use one of the following values:
- quiet|q|silence|s|none|n|0: for no warning or exception
- warn|w|warning|1: for a printed warning
- error|e|raise|r|2: for a raised exceptionExample:
export GIT_PYTHON_REFRESH=quiet
出現(xiàn)這個(gè)問題,主要要了解并解決兩個(gè)問題。
第一個(gè)要解決的問題,自己之前是在github上直接通過下載得到的相關(guān)代碼文件,而不是經(jīng)過git clone命令得到的文件。所以導(dǎo)致git出錯(cuò)。
正確的方法是在github上得到git鏈接(.git形式)
然后在自己本機(jī)的特定目錄下運(yùn)行(xxx.git是在github上得到的git鏈接):
git clone xxx.git
第二個(gè)要解決的問題,要將GIT_PYTHON_GIT_EXECUTABLE設(shè)置為自己本機(jī)中g(shù)it.exe所在的路徑,可以在git bash中輸入where git命令得到git.exe的路徑,比如說路徑為C:\git\bin\git.exe。
在得知這個(gè)路徑后,在自己本機(jī)的特定目錄下運(yùn)行:
set GIT_PYTHON_GIT_EXECUTABLE=C:\git\bin\git.exe
在處理好這兩個(gè)問題后,就沒有出現(xiàn)Bad git executable的bug了,成功解決。
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
pandas數(shù)據(jù)探索之合并數(shù)據(jù)示例詳解
這篇文章主要為大家介紹了pandas數(shù)據(jù)探索之合并數(shù)據(jù)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-10-10Python?4種實(shí)現(xiàn)定時(shí)任務(wù)的方案
這篇文章主要給大家分享了Python?4種實(shí)現(xiàn)定時(shí)任務(wù)的方案,運(yùn)用 while True: + sleep()、Timeloop 庫、threading.Timer 、內(nèi)置模塊 sched ,下面就來看看具體的實(shí)現(xiàn)過程吧2021-12-12python實(shí)現(xiàn)從字符串中找出字符1的位置以及個(gè)數(shù)的方法
這篇文章主要介紹了python實(shí)現(xiàn)從字符串中找出字符1的位置以及個(gè)數(shù)的方法,對(duì)于Python字符串操作的學(xué)習(xí)有一定的幫助與借鑒作用,需要的朋友可以參考下2014-08-08Python實(shí)現(xiàn)拷貝/刪除文件夾的方法詳解
這篇文章主要介紹了Python實(shí)現(xiàn)拷貝/刪除文件夾的方法,涉及Python針對(duì)文件夾的遞歸、遍歷、拷貝、刪除等相關(guān)操作技巧與注意事項(xiàng),需要的朋友可以參考下2018-08-08