首页 > 解决方案 > 安装 Matplotlib 时出错:致命错误 C1083

问题描述

我对 Python 编码比较陌生,想了解 Python 中的统计和数据管理。为此,我想安装 Matplotlib,这给了我一些问题。

我看到其他人有这个问题,但我还没有完全理解如何解决它。

要安装我使用

pip install matplotlib

我安装了以下规格

我遇到的第一个错误是安装 Microsoft Studio,所以我这样做了。我也尝试过更新点子

BUILDING MATPLOTLIB 
 matplotlib: yes [3.1.1] 
 python: yes [3.8.0 (tags/v3.8.0:fa919fd, Oct 14 2019, 19:21:23) [MSC v.1916 32 bit (Intel)]] 
 platform: yes [win32] 

...

 checkdep_freetype2.c
    src/checkdep_freetype2.c(1): fatal error C1083: Cannot open include file: 'ft2build.h': No such file or directory
    error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\BuildTools\\VC\\Tools\\MSVC\\14.23.28105\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1:

标签: pythonmatplotlibinstallation

解决方案


你有 python 3.8,而不是 python 3.7。
但是pypi 上没有可用于 matplotlib 3.1.1 的 python 3.8 轮子。所以最好完全删除 python 3.8 并安装 python 3.7。
然后当你运行python -m pip install matplotlib它时,它会从轮子上安装已编译的版本,因此无需自己编译任何东西或使用 Microsoft Studio。


推荐阅读