python調(diào)用git出錯(cuò)的解決
python調(diào)用git出錯(cuò)
#報(bào)錯(cuò)信息
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Python27\lib\site-packages\git\__init__.py", line 85, in <module>
raise ImportError('Failed to initialize: {0}'.format(exc))
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 exception
Example:
export GIT_PYTHON_REFRESH=quiet
#出錯(cuò)原因:git環(huán)境變量設(shè)置問(wèn)題 #簡(jiǎn)便解決辦法:在導(dǎo)入包的上方增加以下代碼 import os os.environ["GIT_PYTHON_REFRESH"] = "quiet"
python版本不當(dāng)造成git不能使用
1,git錯(cuò)誤(原因是python3軟鏈接由python3.6修改為python3.8了)
root@zjx:/work/share/01-mypipeline# git clone https://gitee.com/ilovevenus/mypipeline.git
Traceback (most recent call last):
File "/usr/lib/command-not-found", line 27, in <module>
from CommandNotFound.util import crash_guard
ModuleNotFoundError: No module named 'CommandNotFound'
2,查看python安裝情況
root@zjx:/work/share/01-mypipeline# ll /usr/bin/python*
lrwxrwxrwx 1 root root 9 4月 16 2018 /usr/bin/python -> python2.7*
lrwxrwxrwx 1 root root 9 4月 16 2018 /usr/bin/python2 -> python2.7*
-rwxr-xr-x 1 root root 3624880 7月 1 23:56 /usr/bin/python2.7*
lrwxrwxrwx 1 root root 22 9月 29 15:12 /usr/bin/python3 -> /work/py/bin/python3.8*
-rwxr-xr-x 1 root root 4526456 11月 7 2019 /usr/bin/python3.6*
-rwxr-xr-x 1 root root 4526456 11月 7 2019 /usr/bin/python3.6m*
lrwxrwxrwx 1 root root 10 9月 29 14:14 /usr/bin/python3m -> python3.6m*
3,刪除軟鏈接并重新設(shè)置軟鏈接,問(wèn)題解決
root@zjx:/work/share/01-mypipeline# rm /usr/bin/python3
root@zjx:/work/share/01-mypipeline# ln -s /usr/bin/python3.6 /usr/bin/python3
root@zjx:/work/share/01-mypipeline# python3
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
Python操作MySQL數(shù)據(jù)庫(kù)實(shí)踐
本文詳細(xì)介紹了Python操作MySQL數(shù)據(jù)庫(kù)的全流程技術(shù),從基礎(chǔ)連接庫(kù)安裝、CRUD操作,到進(jìn)階的連接池優(yōu)化、事務(wù)管理與隔離級(jí)別,并補(bǔ)充了異常處理、SQL注入防護(hù)、批量操作優(yōu)化等知識(shí)點(diǎn),幫助讀者掌握Python操作MySQL的核心技能,適用于運(yùn)維開(kāi)發(fā)及數(shù)據(jù)庫(kù)學(xué)習(xí)者2026-04-04
Django框架實(shí)現(xiàn)的普通登錄案例【使用POST方法】
這篇文章主要介紹了Django框架實(shí)現(xiàn)的普通登錄案例,結(jié)合實(shí)例形式分析了Django框架使用POST方法進(jìn)行頁(yè)面登錄、校驗(yàn)等相關(guān)操作技巧,需要的朋友可以參考下2019-05-05
Python中Dataframe元素為不定長(zhǎng)list時(shí)的拆分分組
本文主要介紹了Python中Dataframe元素為不定長(zhǎng)list時(shí)的拆分分組,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2023-03-03
Python實(shí)現(xiàn)12306自動(dòng)搶火車(chē)票功能
一到國(guó)慶、春節(jié)這種長(zhǎng)假,搶火車(chē)票就非常困難?各大互聯(lián)網(wǎng)公司都推出搶票服務(wù),只要加錢(qián)給服務(wù)費(fèi)就可以增加搶到票的幾率。本文將和你一起探索搶票軟件背后的原理。2021-12-12
使用BeautifulSoup和Pandas進(jìn)行網(wǎng)頁(yè)數(shù)據(jù)抓取與清洗處理
在數(shù)據(jù)分析和機(jī)器學(xué)習(xí)的項(xiàng)目中,數(shù)據(jù)的獲取,清洗和處理是非常關(guān)鍵的步驟,下面我們就來(lái)講講如何利用Python中的Beautiful Soup庫(kù)進(jìn)行這樣的操作吧2025-02-02
Python定時(shí)發(fā)送消息的腳本:每天跟你女朋友說(shuō)晚安
今天小編就為大家分享一篇關(guān)于Python定時(shí)發(fā)送消息的腳本:每天跟你女朋友說(shuō)晚安的文章,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧2018-10-10
關(guān)于python多進(jìn)程中的常用方法詳解
這篇文章主要介紹了關(guān)于python多進(jìn)程中的常用方法詳解,python中的多線(xiàn)程其實(shí)并不是真正的多線(xiàn)程,如果想要充分地使用多核CPU資源,在python中大部分情況需要使用多進(jìn)程,需要的朋友可以參考下2023-07-07
Python實(shí)現(xiàn)數(shù)字小寫(xiě)轉(zhuǎn)大寫(xiě)的示例詳解
這篇文章主要為大家詳細(xì)介紹了如何利用Python實(shí)現(xiàn)數(shù)字小寫(xiě)轉(zhuǎn)大寫(xiě)的功能,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2022-12-12

