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

[debug]-yolov5运行时提示ModuleNotFoundError: No module named ‘_lzma‘

颛孙飞鸾
2023-12-01

Input:

python train.py

Output:

Traceback (most recent call last):                                                                                                                                
  File "train.py", line 24, in <module>                                                                                                                           
    import test  # import test.py to get mAP after each epoch                                                                                                     
  File "/home/user3/yolov5/yolov5/test.py", line 13, in <module>                                                                                                  
    from models.experimental import attempt_load                                                                                                                  
  File "/home/user3/yolov5/yolov5/models/experimental.py", line 7, in <module>                                                                                    
    from models.common import Conv, DWConv                                                                                                                        
  File "/home/user3/yolov5/yolov5/models/common.py", line 9, in <module>                                                                                          
    from utils.datasets import letterbox                                                                                                                          
  File "/home/user3/yolov5/yolov5/utils/datasets.py", line 17, in <module>                                                                                        
    from utils.general import xyxy2xywh, xywh2xyxy, torch_distributed_zero_first                                                                                  
  File "/home/user3/yolov5/yolov5/utils/general.py", line 28, in <module>                                                                                         
    from utils.torch_utils import is_parallel, init_torch_seeds                                                                                                   
  File "/home/user3/yolov5/yolov5/utils/torch_utils.py", line 11, in <module>                                                                                     
    import torchvision                                                                                                                                            
  File "/usr/local/lib/python3.8/site-packages/torchvision/__init__.py", line 7, in <module>                                                                      
    from torchvision import datasets                                                                                                                              
  File "/usr/local/lib/python3.8/site-packages/torchvision/datasets/__init__.py", line 6, in <module>                                                             
    from .mnist import MNIST, EMNIST, FashionMNIST, KMNIST, QMNIST                                                                                                
  File "/usr/local/lib/python3.8/site-packages/torchvision/datasets/mnist.py", line 11, in <module>                                                               
    import lzma                                                                                                                                                   
  File "/usr/local/lib/python3.8/lzma.py", line 27, in <module>                                                                                                   
    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```
 类似资料: