ModuleNotFoundError: No module named '_bz2'

I’ve installed streamlit on my Ubuntu 18.04 LTS with Python 3.9.7 using venv. Tried testing my installation using command:

streamlit hello

and find the following error.
import bz2
File “/usr/local/lib/python3.9/”, line 18, in
from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named ‘_bz2’

I tried installing bz2file from pypi but to no avail.


Hi @sshesh, welcome to the Streamlit community!

This sounds like a system-level issue, as described here:

Installing bz2 via apt seems to be the solution.


Thank you very much @randyzwitch for your help ! It is now working :slightly_smiling_face:

1 Like