Win10+python3.6+git running with problems
Description of the problem
This is a bit of a mystery, basically it's because python can't call git, it's most likely a problem with the environment variables, I've set them and they still don't work.
The following error message is shown below:
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 ()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:
prescription
It's very simple.
Just enter the following command in the small black window:
set GIT_PYTHON_GIT_EXECUTABLE=C:\Program Files\Git\cmd\
It should just be a manual setting of environment variables that will make python call git.
ImportError: Bad git executable error resolution
The specific form of the error is as follows:
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 ()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
There are two main issues to understand and address when this problem arises.
The first problem to be solved, I had previously gotten the relevant code files directly from github via download, instead of the files I got via the git clone command. So it led to git error.
The correct way to do this is to get the git link (.git form) on github
Then run it in a specific directory on your own local machine (it's a git link you get on github):
git clone
The second problem to be solved, to set GIT_PYTHON_GIT_EXECUTABLE to the path where you are located in your own machine, you can enter where git command in the git bash to get the path, for example, the path is C:\git\bin\.
After learning this path, run it in a specific directory on your own local machine:
set GIT_PYTHON_GIT_EXECUTABLE=C:\git\bin\
After taking care of these two issues, there is no more Bad git executable bug, successfully resolved.
summarize
The above is a personal experience, I hope it can give you a reference, and I hope you can support me more.