问题
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