如果你使用的是系统自带的Python2.-7版本,可使用系统的包管理器来安装matplotlib,为此只需执行一行命令:
sudo apt-get install python-matplotlib
如果是python3版本 执行:
sudo apt-get install python3-matplotlib
测试matplotlib
lbrd@lbrd-PC:$ python
Python 2.7.16 (default, Feb 26 2021, 06:12:30)
[GCC 8.3.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import matplotlib
>>>
没有报错,就表明安装成功
测试使用:
新建一个文件:
import matplotlib.pyplot as plt
squares = [1, 4, 7, 10, 13]
plt.plot(squares)
plt.show()