git.exc.GitCommandNotFound:[WinError 5]访问被拒绝

时间:2016-07-05 06:11:45

标签: python git ssh

我正在学习Python。

尝试克隆回购时获得以下异常

    Traceback (most recent call last):
      File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\site-packages\git\cmd.py", line 622, in execute
        **subprocess_kwargs
      File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 969, in __init__
        restore_signals, start_new_session)
      File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\subprocess.py", line 1249, in _execute_child
        startupinfo)
    PermissionError: [WinError 5] Access is denied

    During handling of the above exception, another exception occurred:

    Traceback (most recent call last):
      File "config_console.py", line 2185, in <module>
        command_line = ConfigCommandLine()
      File "config_console.py", line 87, in __init__
        g.clone('git@github.com:Modria/Ecomm_GM.git')
      File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\site-packages\git\cmd.py", line 463, in <lambda>
        return lambda *args, **kwargs: self._call_process(name, *args, **kwargs)
      File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\site-packages\git\cmd.py", line 905, in _call_process
        return self.execute(make_call(), **_kwargs)
      File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\site-packages\git\cmd.py", line 625, in execute
        raise GitCommandNotFound(str(err))
    git.exc.GitCommandNotFound: [WinError 5] Access is denied

安装了GitPython。 ssh密钥在C:\ Users \ Selvakumar.ssh中可用,当我从git bash克隆时它可以正常工作。但同样不能使用python。请注意,生成ssh密钥时没有密码。请帮我解决一下

2 个答案:

答案 0 :(得分:1)

OP确认它是PATH /变量问题

  
    

你的PATH是否引用了git binary?

  
     

是的,那是我做的错误。我在git.exe路径变量中错过了GIT_PYTHON_GIT_EXECUTABLE   像这样C:\Program Files (x86)\Git\bin\git.exe就可以了。

您可以看到该变量已引入here in GitPython 26

  

如果设置,它应该包含git可执行文件的完整路径,例如Windows上为c:\Program Files (x86)\Git\bin\git.exe,Linux上为/usr/bin/git

GitPyhton README州:

  

GitPython需要在系统上安装git可执行文件,并且在PATH中可用于大多数操作。
  如果它不在您的PATH中,您可以通过设置GIT_PYTHON_GIT_EXECUTABLE=<path/to/git>环境变量来帮助GitPython找到它。

答案 1 :(得分:0)

似乎是权限错误,请确保以管理员身份运行脚本