解决:
ModuleNotFoundError: No module named bz2
ModuleNotFoundError: No module named '_lzma'
1、在操作系统中安装zlib和bz2相关库
yum install zlib zlib-devel
yum -y install bzip2 bzip2-devel ncurses openssl openssl-devel openssl-static xz lzma xz-devel sqlite sqlite-devel gdbm gdbm-devel tk tk-devel libffi-devel
2、重新编译
export CFLAGS="-I/usr/include"
export LDFLAGS="-L/usr/lib64"
export LD_LIBRARY_PATH=/usr/lib64 make distclean
./configure --prefix=/usr/local/python3.7 --enable-optimizations && make && make install
其中/usr/include里有bzlib.h,/usr/lib64里有libbz2.so
最后在/home/gt/Py36/lib/python3.6/lib-dynload/得到一个_bz2.cpython-36m-x86_64-linux-gnu.so
就可以import bz2了