自学内容网 自学内容网

解决ImportError: DLL load failed while importing _message: 找不到指定的程序。

C:\software\Anoconda\envs\yolov5_train\python.exe C:\Project\13_yolov5-master\train.py 
C:\software\Anoconda\envs\yolov5_train\lib\site-packages\torchvision\io\image.py:13: UserWarning: Failed to load image Python extension: '[WinError 127] 找不到指定的程序。'If you don't plan on using image functionality from `torchvision.io`, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?
  warn(
Traceback (most recent call last):
  File "C:\Project\13_yolov5-master\train.py", line 55, in <module>
    from utils.loggers import Loggers
  File "C:\Project\13_yolov5-master\utils\loggers\__init__.py", line 12, in <module>
    from torch.utils.tensorboard import SummaryWriter
  File "C:\software\Anoconda\envs\yolov5_train\lib\site-packages\torch\utils\tensorboard\__init__.py", line 12, in <module>
    from .writer import FileWriter, SummaryWriter  # noqa: F401
  File "C:\software\Anoconda\envs\yolov5_train\lib\site-packages\torch\utils\tensorboard\writer.py", line 9, in <module>
    from tensorboard.compat.proto.event_pb2 import SessionLog
  File "C:\software\Anoconda\envs\yolov5_train\lib\site-packages\tensorboard\compat\proto\event_pb2.py", line 8, in <module>
    from google.protobuf import descriptor as _descriptor
  File "C:\software\Anoconda\envs\yolov5_train\lib\site-packages\google\protobuf\descriptor.py", line 28, in <module>
    from google.protobuf.pyext import _message
ImportError: DLL load failed while importing _message: 找不到指定的程序。

创建好conda环境,写好代码以后,代码未出现标红错误,但运行时报错ImportError: DLL load failed while importing _message: 找不到指定的程序;

ImportError DLL load failed的报错,就是写的时候不报错,运行的时候才报错;ModuleNotFoundError: No module named 'XXX'下,在pycharm中写import XXX会标红

错误提示显示 torchvisionprotobuf 在加载某些动态链接库(DLL)时失败,常见原因是缺少依赖库或环境配置不当;通过查询库版本发现是torchvision 版本太高,

torchvision 版本降到0.9.1

但又出现下面的问题:

Traceback (most recent call last):
  File "C:\software\Anoconda\envs\yolov5_train\lib\site-packages\git\__init__.py", line 296, in <module>
    refresh()
  File "C:\software\Anoconda\envs\yolov5_train\lib\site-packages\git\__init__.py", line 287, in refresh
    if not Git.refresh(path=path):
  File "C:\software\Anoconda\envs\yolov5_train\lib\site-packages\git\cmd.py", line 631, 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(<full-path-to-git-executable>)

All git commands will error until this is rectified.

This initial message 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|silent|none|n|0: for no message or exception
    - warn|w|warning|log|l|1: for a warning message (logging level CRITICAL, displayed by default)
    - error|e|exception|raise|r|2: for a raised exception

Example:
    export GIT_PYTHON_REFRESH=quiet

照报错信息,可以找到C:\software\Anoconda\envs\yolov5_train\Lib\site-packages\git\cmd.py(此路径为所配置的环境的目录下),然后打开cmd.py文件,输入代码:

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


原文地址:https://blog.csdn.net/qq_45998729/article/details/143505202

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!