python调用git出错:ImportError: Failed to initialize: Bad git executable.

报错信息

#报错信息
Traceback (most recent call last):
File “”, line 1, in
File “C:\Python27\lib\site-packages\git_init_.py”, line 85, in
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

解决办法

python调用git出错:ImportError: Failed to initialize: Bad git executable._第1张图片
在上图的位置加入:


import os
os.environ["GIT_PYTHON_REFRESH"] = "quiet"

你可能感兴趣的:(日常报错,python,git,开发语言)