简体   繁体   中英

Not able to install bz2 in Python 3

I am not able to install the bz2 package in Python 3 Can please anyone guide

I followed the below commands

sudo yum install bzip2-devel

after that, I start my python 3.7 terminal and use the below command

import bz2

The error:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/sysopt/lib/python3.7/bz2.py", line 19, in <module>
    from _bz2 import BZ2Compressor, BZ2Decompressor
ModuleNotFoundError: No module named '_bz2'

Based on the comments and the /usr/local/sysopt path, I assume you've installed Python 3.7 from a source package.

When you did that, the Python configure script checked whether it has the bits to compile the bz2 module, and as you didn't have bzip2-devel installed during that time, the builtin bz2 module didn't get compiled.

You will need to recompile and reinstall Python 3.7 to get it included. At that point, you may also want to pay heed to any other optional modules that inadvertently don't get installed; sqlite3 tends to usually be one that ends up missing!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM