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

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

  • 原因: yolov5运行时, 如果项目中有.git文件夹, 会检测github远程仓库,所以解决方法分为跳过检测 和 不跳过检测

  • 解决方式 – 不跳过检测

    1. 设置 os.environ[“GIT_PYTHON_REFRESH”] = “quiet”
      import argparse
      import math
      import os
      os.environ["GIT_PYTHON_REFRESH"] = "quiet"
      import random
      import subprocess
      import sys
      import time
      from copy import deepcopy
      from datetime import datetime
      from pathlib import Path
      
    2. 检测过程中会执行git cmd, 所以需要安装git, 否则可能出现如下错误:git.exc.GitCommandNotFound: Cmd('git') not found due to: FileNotFoundError('[WinError 2] 系统找不到指定的文件。') cmdline: git cat-file --batch-check
      安装过程中选择添加git 到系统环境变量, 安装参考: https://blog.youkuaiyun.com/mukes/article/details/115693833
    3. 这种方法可能会因为网络原因导致访问github repo失败
  • 解决方式 – 跳过github检测
    出现这个问题是因为yolov5运行时会进行github 检测, 我们只需要跳过这个检测就可以了, 根据源代码可知, 删除项目中的 .git 文件夹即可. 在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值