1,源码安装bz2
解压tar包
make && make install
2,重新编译Python
其中/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