> ## Content Index
> Fetch the complete content index at: https://sgpublic.xyz/llms.txt
> Use this file to discover other available public pages before exploring further.

# Python 安装 matplot 报错 FreeType version 2.3 or higher is required.
- URL: https://sgpublic.xyz/p/2022/09/6aac9cb1810a4800015335f1/
- Published: 2022-09-30T07:28:54.000Z
- Updated: 2022-09-30T07:28:54.000Z
- Author: Haven Madray
- Tags: 软件开发, Python, #wp-post

Python 安装 matplot 时报错：`FreeType version 2.3 or higher is required.`

```
      x86_64-linux-gnu-gcc -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -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/madray/HoshinoBot/venv/lib/python3.10/site-packages/numpy/core/include -I/home/madray/HoshinoBot/venv/include -I/usr/include/python3.10 -c src/checkdep_freetype2.c -o build/temp.linux-x86_64-3.10/src/checkdep_freetype2.o
      src/checkdep_freetype2.c:3:6: error: #error "FreeType version 2.3 or higher is required. You may set the MPLLOCALFREETYPE environment variable to 1 to let Matplotlib download it."
          3 |     #error "FreeType version 2.3 or higher is required. 
            |      ^~~~~
      src/checkdep_freetype2.c:10:10: error: #include expects "FILENAME" or <FILENAME>
         10 | #include FT_FREETYPE_H
            |          ^~~~~~~~~~~~~
      src/checkdep_freetype2.c:15:9: note: ‘#pragma message: Compiling with FreeType version FREETYPE_MAJOR.FREETYPE_MINOR.FREETYPE_PATCH.’
         15 | #pragma message("Compiling with FreeType version " 
            |         ^~~~~~~
      src/checkdep_freetype2.c:18:4: error: #error "FreeType version 2.3 or higher is required. You may set the MPLLOCALFREETYPE environment variable to 1 to let Matplotlib download it."
         18 |   #error "FreeType version 2.3 or higher is required. 
            |    ^~~~~
      error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
error: legacy-install-failure

× Encountered error while trying to install package.
╰─> matplotlib

note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
```

网上大部分方法都不靠谱，解决方法如下，安装依赖 `libfreetype6-dev` 即可。

```
sudo apt install libfreetype6-dev
```