当前位置: 首页 > news >正文

跑yolov5的train.py时,ImportError: Failed to initialize: Bad git executable.

遇到的问题:

Traceback (most recent call last):File "D:\miniconda\envs\yolov5\lib\site-packages\git\__init__.py", line 296, in <module>refresh()File "D:\miniconda\envs\yolov5\lib\site-packages\git\__init__.py", line 287, in refreshif not Git.refresh(path=path):File "D:\miniconda\envs\yolov5\lib\site-packages\git\cmd.py", line 877, in refreshraise ImportError(err)
ImportError: GIT_PYTHON_REFRESH environment variable has been set but it has been set with an invalid value.Use only the following values:- quiet|q|silence|s|silent|none|n|0: for no message or exception- warn|w|warning|log|l|1: for a warning message (logging level CRITICAL, displayed by default)- error|e|exception|raise|r|2: for a raised exceptionThe above exception was the direct cause of the following exception:Traceback (most recent call last):File "train.py", line 66, in <module>GIT_INFO = check_git_info()File "D:\miniconda\envs\yolov5\lib\contextlib.py", line 75, in innerreturn func(*args, **kwds)File "C:\Users\莫伟铎\Desktop\yolov5-7.0\utils\general.py", line 350, in check_git_infoimport gitFile "D:\miniconda\envs\yolov5\lib\site-packages\git\__init__.py", line 298, in <module>raise ImportError("Failed to initialize: {0}".format(_exc)) from _exc
ImportError: Failed to initialize: GIT_PYTHON_REFRESH environment variable has been set but it has been set 
with an invalid value.Use only the following values:- quiet|q|silence|s|silent|none|n|0: for no message or exception- warn|w|warning|log|l|1: for a warning message (logging level CRITICAL, displayed by default)- error|e|exception|raise|r|2: for a raised exception
 File "D:\miniconda\envs\yolov5\lib\site-packages\git\__init__.py", line 296, in <module>refresh()File "D:\miniconda\envs\yolov5\lib\site-packages\git\__init__.py", line 287, in refreshif not Git.refresh(path=path):File "D:\miniconda\envs\yolov5\lib\site-packages\git\cmd.py", line 860, in refreshraise ImportError(err)
ImportError: 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(<full-path-to-git-executable>)All git commands will error until this is rectified.This initial message 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|silent|none|n|0: for no message or exception- warn|w|warning|log|l|1: for a warning message (logging level CRITICAL, displayed by default)- error|e|exception|raise|r|2: for a raised exceptionExample:export GIT_PYTHON_REFRESH=quietThe above exception was the direct cause of the following exception:Traceback (most recent call last):File "train.py", line 66, in <module>GIT_INFO = check_git_info()File "D:\miniconda\envs\yolov5\lib\contextlib.py", line 75, in innerreturn func(*args, **kwds)File "C:\Users\莫伟铎\Desktop\yolov5-7.0\utils\general.py", line 350, in check_git_infoimport gitFile "D:\miniconda\envs\yolov5\lib\site-packages\git\__init__.py", line 298, in <module>raise ImportError("Failed to initialize: {0}".format(_exc)) from _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(<full-path-to-git-executable>)All git commands will error until this is rectified.This initial message 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|silent|none|n|0: for no message or exception- warn|w|warning|log|l|1: for a warning message (logging level CRITICAL, displayed by default)- error|e|exception|raise|r|2: for a raised exceptionExample:export GIT_PYTHON_REFRESH=quiet

原因:

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(<full-path-to-git-executable>)

解决办法:

下载并安装 Git:

下面是其官网:https://git-scm.com/download/win

点击画圈圈的Click here download,进行下载git

        安装完git后,重启终端(CMD / PowerShell)再运行:输入git --version出现相应的版本号说明安装成功。

git --version
# 应输出:git version 2.x.x

出现下面情况就是安装成功。

然后输入指令:

python train.py

就不会报错了。

http://www.xdnf.cn/news/1248607.html

相关文章:

  • 【Linux】特效爆满的Vim的配置方法 and make/Makefile原理
  • 一种红外遥控RGB灯带控制器-最低价MCU
  • MySQL间隙锁在查询时锁定的范围
  • 前端遇到页面卡顿问题,如何排查和解决?
  • 【运维部署篇】OpenShift:企业级容器应用平台全面解析
  • Spring 的优势
  • Springboot集成Log4j2+MDC串联单次请求的日志
  • HBM Basic(VCU128)
  • 《Python基础》第3期:使用PyCharm编写Hello World
  • Leetcode-2080区间内查询数字的频率
  • 查看部署在K8S服务的资源使用情况
  • LOOP Finance:一场 Web3 共和国中的金融制度实验
  • 创维智能融合终端DT741_移动版_S905L3芯片_安卓9_线刷固件包
  • Linux驱动24 --- RkMedia 视频 API 使用
  • 前端保持和服务器时间同步的方法【使用vue3举例】
  • Tasks and Deadlines(Sorting and Searching)
  • Mysql-事务
  • Nginx入门:高性能Web服务器详解
  • 【图像算法 - 09】基于深度学习的烟雾检测:从算法原理到工程实现,完整实战指南
  • Claude Code实战体验:AI智能编程助手如何重塑开发工作流?
  • 2. JS 有哪些数据类型
  • Linux的NFS与Autofs配置指南
  • nodejs 编程基础01-NPM包管理
  • 最优化中常见的优化理论
  • Shader开发(七)创建第一个Shader项目
  • 游戏画面总是卡顿怎么办 告别延迟畅玩游戏
  • DDoS 防护的未来趋势AI 如何改变安全行业
  • MySQL 5.7 和 8.0 离线安装教程(图文版适合电脑小白)
  • C++返回值优化(RVO):高效返回对象的艺术
  • 【基础】第八篇 Java 位运算符详解:从基础到实战应用