当前位置: 首页 > 工具软件 > LZMA Utils > 使用案例 >

python no module name _lzma_[调试]-yolov5运行时提示modulenotfounderror:没有名为''lzma'的模块,debugyolov5,ModuleNot...

谢雅珺
2023-12-01

Input:

python train.py

Output:

Traceback (most recent call last):

File "train.py", line 24, in

import test # import test.py to get mAP after each epoch

File "/home/user3/yolov5/yolov5/test.py", line 13, in

from models.experimental import attempt_load

File "/home/user3/yolov5/yolov5/models/experimental.py", line 7, in

from models.common import Conv, DWConv

File "/home/user3/yolov5/yolov5/models/common.py", line 9, in

from utils.datasets import letterbox

File "/home/user3/yolov5/yolov5/utils/datasets.py", line 17, in

from utils.general import xyxy2xywh, xywh2xyxy, torch_distributed_zero_first

File "/home/user3/yolov5/yolov5/utils/general.py", line 28, in

from utils.torch_utils import is_parallel, init_torch_seeds

File "/home/user3/yolov5/yolov5/utils/torch_utils.py", line 11, in

import torchvision

File "/usr/local/lib/python3.8/site-packages/torchvision/__init__.py", line 7, in

from torchvision import datasets

File "/usr/local/lib/python3.8/site-packages/torchvision/datasets/__init__.py", line 6, in

from .mnist import MNIST, EMNIST, FashionMNIST, KMNIST, QMNIST

File "/usr/local/lib/python3.8/site-packages/torchvision/datasets/mnist.py", line 11, in

import lzma

File "/usr/local/lib/python3.8/lzma.py", line 27, in

from _lzma import *

ModuleNotFoundError: No module named '_lzma'

Environment

OS: [centos7]

GPU [tesla v100]

python_version [3.8.3]

cuda [9.2]

torch [1.7.0]

torchvison [0.8.1]

yolov5 [v3.1]

Solution

1.frist

yum install xz-devel

yum install python-backports-lzma

pip install backports.lzma

2.second

cd /usr/local/lib/python3.8

vi lzma.py

3.finally

modify about line 27

try:

from _lzma import *

from _lzma import _encode_filter_properties, _decode_filter_properties

except ImportError:

from backports.lzma import *

from backports.lzma import _encode_filter_properties, _decode_filter_properties```

 类似资料: