This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Fails to import bz2 on Ubuntu
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: eric.smith, serhiy.storchaka, xxm
Priority: normal Keywords:

Created on 2021-03-11 07:20 by xxm, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (4)
msg388483 - (view) Author: Xinmeng Xia (xxm) Date: 2021-03-11 07:20
Module bz2 fails to be imported on Ubuntu due to lack of '_bz2'.  We try "import bz2" on Mac, it can work well.

Errors on Ubuntu
>>import bz2
Traceback (most recent call last):
      File "/home/xxm/Desktop/apifuzz/doc/", line 97, in <module>
      File "", line 1, in <module>
           File "/home/xxm/Desktop/apifuzz/Python-3.9.2/Lib/", line 18, in <module>
                from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'

Python version: 3.9.2
Python installation: (1). download source code from, (2). run command "./configure; sudo make; sudo make install.

We install the same Python 3.9.2 in a same way on Mac and Ubuntu.
msg388484 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-03-11 07:36
You're probably missing needed dependencies. For example, see

If you look at the output of make, you should be able to see that _bz2 wasn't built.
msg388537 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-03-12 10:21
You are likely did not have headers for bz2 library installed. Read thoughtfully the output of ./configure and make.

See also .
msg388941 - (view) Author: Eric V. Smith (eric.smith) * (Python committer) Date: 2021-03-17 17:15
I'm going to close this. @xmm: If you can provide more information showing that this is a bug in Python or its build process, please re-open this issue.
Date User Action Args
2022-04-11 14:59:42adminsetgithub: 87637
2021-03-17 17:15:29eric.smithsetstatus: open -> closed
resolution: not a bug
messages: + msg388941

stage: resolved
2021-03-12 10:21:36serhiy.storchakasetstatus: pending -> open
nosy: + serhiy.storchaka
messages: + msg388537

2021-03-12 00:00:27eric.smithsetstatus: open -> pending
2021-03-11 07:36:23eric.smithsetnosy: + eric.smith
messages: + msg388484
2021-03-11 07:20:37xxmcreate