当前位置: 首页> 汽车> 行情 > 企业运营方案_西安网络推广公司网络推广_谷歌商店官网_指数查询

企业运营方案_西安网络推广公司网络推广_谷歌商店官网_指数查询

时间:2025/8/23 8:32:35来源:https://blog.csdn.net/jaket5219999/article/details/142371274 浏览次数: 0次
企业运营方案_西安网络推广公司网络推广_谷歌商店官网_指数查询

- demo.py

import os
import sys
from contextlib import contextmanager
from pathlib import Pathimport yaml
from tqdm import tqdmFILE = Path(__file__).resolve()
ROOT = FILE.parents[3]  # YOLOv5 root directory
if str(ROOT) not in sys.path:sys.path.append(str(ROOT))  # add ROOT to PATHfrom utils.dataloaders import LoadImagesAndLabels, img2label_paths
from utils.general import LOGGER, check_dataset, check_filetry:import wandbassert hasattr(wandb, "__version__")  # verify package import not local dir
except (ImportError, AssertionError):wandb = Noneprint(os, sys, contextmanager, yaml, tqdm, LoadImagesAndLabels, img2label_paths, LOGGER, check_dataset, check_file, wandb)

执行命令:ruff check demo.py

报错如下:

demo.py:14:1: E402 Module level import not at top of file|
12 |     sys.path.append(str(ROOT))  # add ROOT to PATH
13 |
14 | from utils.dataloaders import LoadImagesAndLabels, img2label_paths| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E402
15 | from utils.general import LOGGER, check_dataset, check_file|demo.py:15:1: E402 Module level import not at top of file|
14 | from utils.dataloaders import LoadImagesAndLabels, img2label_paths
15 | from utils.general import LOGGER, check_dataset, check_file| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ E402
16 |
17 | try:|Found 2 errors.

解决:把后面的import放到suppress里

import os
import sys
from contextlib import contextmanager, suppress
from pathlib import Pathimport yaml
from tqdm import tqdmFILE = Path(__file__).resolve()
ROOT = FILE.parents[3]  # YOLOv5 root directory
if str(ROOT) not in sys.path:sys.path.append(str(ROOT))  # add ROOT to PATHwith suppress(FutureWarning):from utils.dataloaders import LoadImagesAndLabels, img2label_pathsfrom utils.general import LOGGER, check_dataset, check_filetry:import wandbassert hasattr(wandb, "__version__")  # verify package import not local dir
except (ImportError, AssertionError):wandb = Noneprint(os, sys, contextmanager, yaml, tqdm, LoadImagesAndLabels, img2label_paths, LOGGER, check_dataset, check_file, wandb)

前后版本对比如下:

关键字:企业运营方案_西安网络推广公司网络推广_谷歌商店官网_指数查询

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: