Python 3 reported an error: modulenotfounderror: no module named ‘_ bz2’
system information
System: Ubuntu 1804 lts
Python version: Python 3.7
Error message
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'
Solution:
1. installation
sudo apt install bzip2-devel
2. Find the file _bz2.cpython-37m-x86_64-linux-gnu.so
3. Modify the file name
If your python version is 3.6, it is 36m, mine is python3.7, you have to change the file name to 37m, and copy it to the python3 installation directory
mv _bz2.cpython-36m-x86_64-linux-gnu.so _bz2.cpython-37m-x86_64-linux-gnu.so
cp _bz2.cpython-37m-x86_64-linux-gnu.so /usr/local/python3/lib/python3.7/lib-dynload/