Cyber_Pig_908
Cyber_Pig_908

Reputation: 61

How to install gitpython with, Failed to initialize: Bad git executable

I am trying to install git-python on Windows. I tried to install it using the git command:

pip install gitpython

It installed just fine and it install in my local app data. The only problem was is when I ran it, it gave me this error:

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()

In addition I ran pip install gitpython:

Requirement already satisfied: gitpython in c:\users\morga\appdata\local\programs\python\python38-32\lib\site-packages (3.1.3)
Requirement already satisfied: gitdb<5,>=4.0.1 in c:\users\morga\appdata\local\programs\python\python38-32\lib\site-packages (from gitpython) (4.0.5)
Requirement already satisfied: smmap<4,>=3.0.1 in c:\users\morga\appdata\local\programs\python\python38-32\lib\site-packages (from gitdb<5,>=4.0.1->gitpython) (3.0.4)

I do not have it the folder of git. I only found anything remotely to git was in my appdata local

Upvotes: 5

Views: 6601

Answers (2)

HIC
HIC

Reputation: 1

I think this has worked for me. I didnt want python installed globally, but i think its contained in visual studio at least

set

GIT_PYTHON_GIT_EXECUTABLE="C:\Users\<YOUR_USERNAME>\AppData\Roaming\Python\Python39\site-packages\git"

However, putting it in Path Environment Variables I am still getting the same error. Other environment variables can be run by putting two %% around the Name and run in Command Prompt.

I am research what the other two solutions: GIT_PYTHON_GIT_EXECUTABLE and git.refresh()

mean

Upvotes: 0

VonC
VonC

Reputation: 1327074

As in issue 816, check your GIT_PYTHON_GIT_EXECUTABLE environment variable:

C:\>:: This does NOT work
C:\>set GIT_PYTHON_GIT_EXECUTABLE="C:\Program Files\Git\cmd\git.exe"
C:\>%GIT_PYTHON_GIT_EXECUTABLE% --version
git version 2.20.1.windows.1

C:\>:: This does work
C:\>set GIT_PYTHON_GIT_EXECUTABLE=C:\Program Files\Git\cmd\git.exe

Replace C:\Program Files\Git\ by your own Git installation folder (using, as noted by Jeromy Adofo, where git).
If you don't have Git installed, you can installed the latest Git For Windows.

Upvotes: 8

Related Questions