ImportError: Bad git executable错误的解决方案
错误具体形式如下: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- exp
文章共468字 · 阅读需要大约2分钟
一键AI生成摘要,助你高效阅读
问答
·
错误具体形式如下:
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
出现这个问题,主要要了解并解决两个问题。
第一个要解决的问题,自己之前是在github上直接通过下载得到的相关代码文件,而不是经过git clone命令得到的文件。所以导致git出错。
正确的方法是在github上得到git链接(.git形式)
然后在自己本机的特定目录下运行(xxx.git是在github上得到的git链接):
git clone xxx.git
第二个要解决的问题,要将GIT_PYTHON_GIT_EXECUTABLE设置为自己本机中git.exe所在的路径,可以在git bash中输入where git命令得到git.exe的路径,比如说路径为C:\git\bin\git.exe。在得知这个路径后,在自己本机的特定目录下运行:
set GIT_PYTHON_GIT_EXECUTABLE=C:\git\bin\git.exe
在处理好这两个问题后,就没有出现Bad git executable的bug了,成功解决。
更多推荐
已为社区贡献1条内容
所有评论(0)