解决CentOS pyhon3 ModuleNotFoundError: No module named "_bz2"问题
在运行Python项目的时候出现了No module named '_bz2'错误
File "<frozen importlib._bootstrap>", line 1206, in _gcd_import File "<frozen importlib._bootstrap>", line 1178, in _find_and_load File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 690, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 940, in exec_module File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed File "/software/architonic/architonic_p3/lib/python3.11/site-packages/scrapy/extensions/feedexport.py", line 23, in <module> from scrapy.extensions.postprocessing import PostProcessingManager File "/software/architonic/architonic_p3/lib/python3.11/site-packages/scrapy/extensions/postprocessing.py", line 4, in <module> from bz2 import BZ2File File "/usr/local/python3/lib/python3.11/bz2.py", line 17, in <module> from _bz2 import BZ2Compressor, BZ2Decompressor ModuleNotFoundError: No module named '_bz2'
解决办法
先安装bzip2 bzip2-devel
yum -y install bzip2 bzip2-devel
其次重新编译Python3
./configure --prefix=/usr/local/python3 --with-ssl --enable-optimozations make && make install
至此,错误解决