5

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

2 Answers 2

8

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.

Sign up to request clarification or add additional context in comments.

9 Comments

%GIT_PYTHON_GIT_EXECUTABLE% --version The system cannot find the path specified.
@Cyber_Pig_908 Yes, that is expected. Does it work in gitpython though?
I am sorry. I do not understand. Do I run it and cmd as admin?
No, regular account only
It still did not work. I don't if this helps but I don't have git in program files. I just have it in Appdata local
|
0

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

1 Comment

Do I need a $ infront of GIT_PYTHON_GIT_EXECUTABLE="C:\Users\...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.