下载好yolov5,跑train.py报错,用debug跳到了__init__.py小面图片小闪电这个位置,不知道怎么改,最下面的代码是运行train.py的报错。
Traceback (most recent call last):
File "D:\xunlei\ANACADON3\envs\pytorch\lib\site-packages\git\__init__.py", line 89, in <module>
refresh()
File "D:\xunlei\ANACADON3\envs\pytorch\lib\site-packages\git\__init__.py", line 76, in refresh
if not Git.refresh(path=path):
File "D:\xunlei\ANACADON3\envs\pytorch\lib\site-packages\git\cmd.py", line 392, in refresh
raise 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()
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 exception
Example:
export GIT_PYTHON_REFRESH=quiet
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "D:\2anaconda\yolov5-master\train.py", line 72, in <module>
GIT_INFO = check_git_info()
File "D:\xunlei\ANACADON3\envs\pytorch\lib\contextlib.py", line 75, in inner
return func(*args, **kwds)
File "D:\2anaconda\yolov5-master\utils\general.py", line 360, in check_git_info
import git
File "D:\xunlei\ANACADON3\envs\pytorch\lib\site-packages\git\__init__.py", line 91, 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()
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 exception
Example:
export GIT_PYTHON_REFRESH=quiet
进程已结束,退出代码1
是不是git环境变量没配置正确?
ImportError: Bad git executable.
git没有装对吧。
这个报错是说没有找到git可执行文件,你先确认一下电脑装了官方git没有
如果有的话,看下有没有环境变量
不知道你这个问题是否已经解决, 如果还没有解决的话:# Create model
model = Model(opt.cfg).to(device)
assert model.md['nc'] == nc, '%s nc=%g classes but %s nc=%g classes' % (opt.data, nc, opt.cfg, model.md['nc'])
model.names = data_dict['names']
参考链接assert是一个判断表达式,在assert后面成立时创建模型。