当前位置:   article > 正文

Pycharm运行yolov5报错Error: Failed to initialize: Bad git executable.错误的解决方案_运行yolov5时报错git

运行yolov5时报错git

一、报错代码

  1. ImportError: Failed to initialize: Bad git executable.
  2. The git executable must be specified in one of the following ways:
  3. - be included in your $PATH
  4. - be set via $GIT_PYTHON_GIT_EXECUTABLE
  5. - explicitly set via git.refresh()
  6. All git commands will error until this is rectified.
  7. This initial warning can be silenced or aggravated in the future by setting the
  8. $GIT_PYTHON_REFRESH environment variable. Use one of the following values:
  9. - quiet|q|silence|s|none|n|0: for no warning or exception
  10. - warn|w|warning|1: for a printed warning
  11. - error|e|raise|r|2: for a raised exception
  12. Example:
  13. export GIT_PYTHON_REFRESH=quiet

 二、解决办法

1、第一种是直接在train.py文件夹的import os后面加

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

2、第二种是更改git链接

之前是在github上直接通过下载得到的相关代码文件,而不是经过git clone命令得到的文件。所以导致git出错。正确的方法是在github上得到git链接(.git形式)然后在自己本机的特定目录下运行

git clone xxx.git

将GIT_PYTHON_GIT_EXECUTABLE设置为自己本机中git.exe所在的路径,如路径为C:\program\git\bin\git.exe。在得知这个路径后,在自己本机的特定目录下运行:

set GIT_PYTHON_GIT_EXECUTABLE=C:\git\bin\git.exe
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/507551
推荐阅读
相关标签
  

闽ICP备14008679号