No module named '_bz2' in python3

狂风中的少年 提交于 2020-04-12 17:04:50

问题


When trying to execute the following command:

import matplotlib.pyplot as plt

The following error occurs:

from _bz2 import BZ2Compressor, BZ2Decompressor ImportError: No module named '_bz2'

So, I was trying to install bzip2 module in Ubuntu using :

sudo pip3 install bzip2

But, the following statement pops up in the terminal:

Could not find a version that satisfies the requirement bzip2 (from versions: ) No matching distribution found for bzip2

What can I do to solve the problem?


回答1:


If you compiling python yourself, you need to install libbz2 headers and .so fiels first, so that python will bu compiled with bz2 support.

On ubuntu, apt-get install libbz2-dev then compile python.



来源:https://stackoverflow.com/questions/50335503/no-module-named-bz2-in-python3

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!