- 系统:Centos
- python版本: python3.7
- 安装底层库:
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel python-devel python3-devel
解决 _bz2
只需要安装 zlib-devel
bzip2-devel
即可,如果你想避免以后遇到 _bz2
这样恶心的报错,那你听我的,全装了吧。
- 重新安装编译python3.7
- 测试导入
bz2
不报错
$python3.7
Python 3.7.4 (default, Mar 31 2022, 18:36:57)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)] on linux
Type "help", "copyright", "credits" or "license" for more information.
import bz2
- 解决