当前位置: 首页 > 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.dtcms.com/a/316932.html

相关文章:

  • Android 之 Kotlin中的kapt
  • io_uring系统调用及示例
  • Houdini Pyro学习笔记
  • [数组]977.有序数组的平方;209.长度最小的子数组
  • VUE+SPRINGBOOT从0-1打造前后端-前后台系统-邮箱重置密码
  • 数据结构——双向链表
  • 【学习嵌入式day-17-数据结构-单向链表/双向链表】
  • C语言:预处理、 库文件、 文件IO
  • Python深度学习:从入门到进阶
  • GPT-1、GPT-2、GPT-3 的区别和联系
  • C语言基础_IDE、进制转换、基本数据类型、输入输出函数、运算符
  • 一文搞定JavaServerPages基础,从0开始写一个登录与人数统计页面
  • 模拟面试总结
  • JSP相关Bug解决
  • Vue.js 教程
  • 市场与销售协同:CRM如何打破部门数据孤岛?
  • 思途Mybatis学习 0805
  • 一个小巧神奇的 USB数据线检测仪
  • LabVIEW 2025 安装攻略(附图文教程)适用于测试与自动控制领域
  • 亚马逊广告进阶指南:大词 VS 长尾词
  • 数据结构2.(双向链表,循环链表及内核链表)
  • 怎么在公司存活下去
  • SAP FI模块凭证增强逻辑的策略
  • 飞算 JavaAI:开启 Java 开发智能自动化新时代
  • open3d python 鞋底点云点胶路径识别
  • windows 系统装机入职版
  • Java 模版进阶
  • C#案例实战
  • 18day-人工智能-机器学习-分类算法-朴素贝叶斯分类
  • 8.5学习总结