运行训练脚本显示如下错误:
File “/usr/local/python3.7.5/lib/python3.7/lzma.py”,line27,in <module>
from _lzma import*
ModuleNotFoundError: No module named '_lzma'
python 3.3版本以上会自带lzma模块,可是如果用户是通过源码安装的python,而且系统中没有安装lzma-dev包,那么就不会安装lzma模块。
apt-get install -y liblzma-dev
yum install -y xz-devel python-backports-lzma
pip3 install backports.lzma
vi /usr/local/python3.7.5/lib/python3.7/lzma.py
在文件/usr/local/python3.7.5/lib/python3.7/lzma.py,line27行,修改如下:
# 修改前
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