我正在学习 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?
是的,这就是我犯的错误。我错过了
block 引用>git.exe
在GIT_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.GitPython needs the git executable to be installed on the system and available in your
PATH
for most operations.
If it is not in yourPATH
, you can help GitPython find it by setting theGIT_PYTHON_GIT_EXECUTABLE=<path/to/git>
environment variable.
关于python - git.exc.GitCommandNotFound : [WinError 5] Access is denied,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38196318/