Skip to content

Windows - ImportError: Failed to initialize: Bad git executable. #816

Closed
@vesche

Description

@vesche

OS - Win 2012 R2
Python - 2.7.13
git - version 2.20.1.windows.1
GitPython - 2.1.11

GitPython not finding my git.exe binary? C:\Program Files (x86)\Git\cmd is in my PATH. I then explicitly set GIT_PYTHON_GIT_EXECUTABLE as #26 recommends.

C:\Users\Administrator\Desktop>python --version
Python 2.7.13

C:\Users\Administrator\Desktop>pip freeze | findstr /i git
←[33mYou are using pip version 9.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' comm
and.←[0m
gitdb2==2.0.5
GitPython==2.1.11

C:\Users\Administrator\Desktop>echo %GIT_PYTHON_GIT_EXECUTABLE%
"C:\Program Files (x86)\Git\cmd\git.exe"

C:\Users\Administrator\Desktop>%GIT_PYTHON_GIT_EXECUTABLE% --version
git version 2.20.1.windows.1

C:\Users\Administrator\Desktop>python -c "import git"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Python27\lib\site-packages\git\__init__.py", line 85, in <module>
    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions