在利用深度学习服务器,利用Xshell进入端口,想要运行深度学习项目时碰到了以下错误:
Traceback (most recent call last):
File "/opt/conda/envs/[yolov5_SE]/lib/python3.9/site-packages/git/__init__.py", line 166, in <module>
refresh()
File "/opt/conda/envs/[yolov5_SE]/lib/python3.9/site-packages/git/__init__.py", line 153, in refresh
if not Git.refresh(path=path):
File "/opt/conda/envs/[yolov5_SE]/lib/python3.9/site-packages/git/cmd.py", line 391, 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 "/root/yolov5-master/yolov5-master/train.py", line 73, in <module>
GIT_INFO = check_git_info()
File "/opt/conda/envs/[yolov5_SE]/lib/python3.9/contextlib.py", line 79, in inner
return func(*args, **kwds)
File "/root/yolov5-master/yolov5-master/utils/general.py", line 370, in check_git_info
import git
File "/opt/conda/envs/[yolov5_SE]/lib/python3.9/site-packages/git/__init__.py", line 168, 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
这个错误表明你的环境中存在与git可执行文件相关的问题。错误提示你需要通过以下方式之一指定git可执行文件的位置:
- 包含在你的PATH中
- 通过GIT_PYTHON_GIT_EXECUTABLE设置
- 通过git.refresh()显式设置
你可以通过以下方法解决这个问题:
-
确保git可执行文件在系统的PATH中。你可以在终端中运行
git --version
来检查git是否安装。如果没有安装,你需要先安装git。 -
将GIT_PYTHON_GIT_EXECUTABLE环境变量设置为git可执行文件的路径。
-
通过代码使用
git.refresh()
来显式设置git可执行文件的路径。文章来源:https://www.toymoban.com/news/detail-787988.html
最终我通过输入以下命令即可完美解决。文章来源地址https://www.toymoban.com/news/detail-787988.html
export GIT_PYTHON_REFRESH=quiet
到了这里,关于Linux服务器报错解决The git executable must be specified in one of the following ways: - be included in的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!