问题描述
Im试图在spyder中使用gitpython克隆git repo。 即时通讯使用下面的代码。
from git import Repo
full_local_path = r'C:/New/Newfolder'
remote = f"https://(git path)/*/frontend_backup.git"
Repo.clone_from(remote,full_local_path)
但是我遇到了错误
GitCommandNotFound: Cmd('git') not found due to: FileNotFoundError('[WinError 2] The system cannot find the file specified')
cmdline: git clone -v https://(git path)/*/frontend_backup.git C:/New/Newfolder
在Anaconda Prompt中执行时,相同的命令已成功执行,但是在Spyder中尝试执行相同的命令时,得到了这样的错误。
注意:我已经在系统变量中给出了git.exe和python.exe的路径。
解决方法
找到答案。
这是因为我使用Spyder的anaconda环境(基础)没有安装git版本。 基本的环境不允许您安装其他软件包,您必须创建另一个环境并安装所需的所有软件包。 我在anaconda中创建了另一个env,它解决了错误。