python - git.exc.GitCommandNotFound : [WinError 5] Access is denied

标签 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 key 在 C:\Users\Selvakumar.ssh 中可用,当我从 git bash 克隆时它可以工作。但同样的情况在 python 上不起作用。请注意,生成的 ssh key 没有密码。请帮我解决一下

最佳答案

OP 确认这是一个 PATH/变量问题

Does your PATH references git binary?

是的,这就是我犯的错误。我错过了git.exeGIT_PYTHON_GIT_EXECUTABLE路径变量。
像这样给出 C:\Program Files (x86)\Git\bin\git.exe并且它有效。

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

If set, it should contain the full path to the git executable, e.g. c:\Program Files (x86)\Git\bin\git.exe on windows or /usr/bin/git on linux.

GitPyhton README状态:

GitPython needs the git executable to be installed on the system and available in your PATH for most operations.
If it is not in your PATH, you can help GitPython find it by setting the GIT_PYTHON_GIT_EXECUTABLE=<path/to/git> environment variable.

关于python - git.exc.GitCommandNotFound : [WinError 5] Access is denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38196318/

相关文章:

python - Pandas 中的 If-else 条件赋值

git clone --bare 不包括分支 master

git - 基于 kohana 的项目的源代码控制结构

javascript - 使用来自 SSH2 的 SFTP 对象

ssh - Ansible 无法使用不同用户在本地主机上创建文件夹

java - 使用 Jsch 检查 SFTP 权限

javascript - Google BigQuery Python 库下载结果的速度是 Node JS 库的 2 倍

python - GridsearchCV 和 Kfold 交叉验证

python - Keras LSTM - 使用生成器中的 Tensorflow 数据集 API 提供序列数据

git - pull 远程存储库并推送这些文件