Linux服务器报错解决The git executable must be specified in one of the following ways: - be included in

这篇具有很好参考价值的文章主要介绍了Linux服务器报错解决The git executable must be specified in one of the following ways: - be included in。希望对大家有所帮助。如果存在错误或未考虑完全的地方,请大家不吝赐教,您也可以点击"举报违法"按钮提交疑问。

在利用深度学习服务器,利用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可执行文件的位置:

  1. 包含在你的PATH中
  2. 通过GIT_PYTHON_GIT_EXECUTABLE设置
  3. 通过git.refresh()显式设置

你可以通过以下方法解决这个问题:

  1. 确保git可执行文件在系统的PATH中。你可以在终端中运行 git --version 来检查git是否安装。如果没有安装,你需要先安装git。

  2. 将GIT_PYTHON_GIT_EXECUTABLE环境变量设置为git可执行文件的路径。

  3. 通过代码使用git.refresh()来显式设置git可执行文件的路径。

最终我通过输入以下命令即可完美解决。文章来源地址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模板网!

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处: 如若内容造成侵权/违法违规/事实不符,请点击违法举报进行投诉反馈,一经查实,立即删除!

领支付宝红包 赞助服务器费用

相关文章

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

博客赞助

微信扫一扫打赏

请作者喝杯咖啡吧~博客赞助

支付宝扫一扫领取红包,优惠每天领

二维码1

领取红包

二维码2

领红包