1,源码安装bz2
解压tar包
make && make install
2,重新编译Python

export CFLAGS="-I/usr/include"
export LDFLAGS="-L/usr/lib64"
export LD_LIBRARY_PATH=/usr/lib64

make distclean
./configure --prefix=/home/gt/Py36 && 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​​了

参考
stackoverflow.com/questions/13915137/how-do-you-assign-bz2-to-an-altinstall-of-python
stackoverflow.com/questions/23548188/how-do-i-compile-python-3-4-with-custom-openssl