Python3.6.3, ModuleNotFoundError: No module named '_bz2'

DunkOnly picture DunkOnly · Oct 30, 2017 · Viewed 11.2k times · Source

In Linux, CentOS

I download the bzip tar file(bzip2-1.0.6.tar.gz) and

make && make install

Then I recompile Python-3.6.3

./configure --prefix=/home/gt/Py36
make && make install

Then I import bz2 in /home/gt/Py36/bin/python3 and get

ModuleNotFoundError: No module named '_bz2'

Then I

cp /usr/lib64/python2.7/lib-dynload/bz2.so /home/gt/Py36/lib/python3.6/

Then I get

ImportError: dynamic module does not define module export function (PyInit_bz2)

when import bz2

Answer