小工具知识网

当前位置: 首页 > 行业知识 > YOLOv5运行错误:ImportError: Failed to initialize: Bad git executable.

行业知识

YOLOv5运行错误:ImportError: Failed to initialize: Bad git executable.

2026-11-13 18:03:43 来源:互联网转载

问题���述:我们在跑YOLOv5官方数据集时,出现这个错误,ImportError: Failed to initialize: Bad git executable.

()

具体错误如下

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()All git commands will error until this is rectified.This initial warning 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|none|n|0: for no warning or exception    - warn|w|warning|1: for a printed warning    - error|e|raise|r|2: for a raised exceptionExample:    export GIT_PYTHON_REFRESH=quiet

具体原因:未知

()

解决办法:

在train.py文件中的import os后面加上

os.environ["GIT_PYTHON_REFRESH"] = "quiet"

具体位置

import argparseimport mathimport osos.environ["GIT_PYTHON_REFRESH"] = "quiet"import randomimport subprocessimport sysimport timefrom copy import deepcopyfrom datetime import datetimefrom pathlib import Path

上一篇:揭秘三星云,云端奥秘与数字化转型领航者

下一篇:揭秘IPvUV,未来网络的新概念引领潮流!