python中没有匹配的模块,python3中没有名为“ _bz2”的模块

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?

解决方案

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.

你可能感兴趣的:(python中没有匹配的模块)