Python运行异常UserWarning:Could not import the lzma module .Your installed Python is incomplete.

执行python脚本时,报错

 在linux服务器上运行

yum install xz-devel -y
yum install python-backports-lzma -y
pip install backports.lzma

然后找到/usr/local/python3/lib/python3.7目录(机器不同,目录也有所不同,可以通过which命令来查找当前运行python是使用的那个目录的),然后编辑lzma.py,将:

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

 

posted @ 2021-02-23 13:58  chillax1314  阅读(3605)  评论(0)    收藏  举报