python报错ModuleNotFoundError_No_module_named_lzma

执行Python脚本时报错

 File "/usr/local/python3.9/lib/python3.9/site-packages/pooch/processors.py", line 14, in <module>
    import lzma
  File "/usr/local/python3.9/lib/python3.9/lzma.py", line 27, in <module>
    from _lzma import *
ModuleNotFoundError: No module named '_lzma'

修复方法一:backports

yum install xz-devel -y
yum install python-backports-lzma -y
pip3.9 install backports.lzma

#修改前
from _lzma import *
from _lzma import _encode_filter_properties, _decode_filter_properties

#修改后 
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

修复方法二:python-backports-lzma

yum install xz-devel -y
yum install python-backports-lzma -y
>> Home

51ak

2023/11/23

Categories: 报错 python centos Tags: 基础

《数据库工作笔记》公众号
扫描上面的二维码,关注我的《数据库工作笔记》公众号