在win下安装matplotlib,直接pip install matplotlib即可。
但是linux mint 下老是出错误提示:
i686-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DFREETYPE_BUILD_TYPE=system -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_ft2font_ARRAY_API -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D__STDC_FORMAT_MACROS=1 -Iextern/agg24-svn/include -I/home/oliveryty/.local/lib/python3.6/site-packages/numpy/core/include -I/usr/include/python3.6m -c src/checkdep_freetype2.c -o build/temp.linux-i686-3.6/src/checkdep_freetype2.o
src/checkdep_freetype2.c:1:10: fatal error: ft2build.h: No such file or directory
#include <ft2build.h>
^~~~~~~~~~~~
compilation terminated.
error: command 'i686-linux-gnu-gcc' failed with exit status 1
百度一下,发现可能需要使用apt-get 下载,于是先用apt search 搜索一下:
~$ sudo apt search matplotlib
p python-matplotlib - Python based plotting system in a style si
p python-matplotlib-data - Python based plotting system (data package
p python-matplotlib-dbg - Python based plotting system (debug extens
p python-matplotlib-doc - Python based plotting system (documentatio
p python-matplotlib-venn - Python plotting area-proportional two- and
p python3-matplotlib - Python based plotting system in a style si
p python3-matplotlib-dbg - Python based plotting system (debug extens
p python3-matplotlib-venn - Python 3 plotting area-proportional two- a
我们需要的是python3-matplotlib:
sudo apt install python3-matplotlib
安装成功后,直接到idle里import 一下试试
>>> import matplotlib
>>>
没有错误提示,说明成功。