user8952913
user8952913

Reputation:

Installing Matplotlib on Windows ERROR - cannot open include file 'ft2build.h'

I am trying to install matplotlib using:

pip install matplotlib

However, I keep getting this error:

- cannot open include file 'ft2build.h' no such file or directory

Error Image

Upvotes: -1

Views: 2638

Answers (2)

FlyingTeller
FlyingTeller

Reputation: 20599

You are using python 3.8 for which no pre-built whl files are avialable on pypi, therefore your pip is attempting to build matplotlib from source. For this, you need to have downloaded and installed the dependencies of matplotlib. In this case, ft2build.h is missing which is part of the freetype library.

If you really want to build from source, there is a script based solution from the matplotlib developers to download and install all neccessary dependencies.


Since you probably don't care about building from source (which can be quite some work on Windows), you should instead consider one of these options:

  1. Install a python version other than 3.8, it is very new and therefore there is not always an official pre-built whl file for modules you want to use
  2. As MrFuppes suggested, download matplotlib‑3.2.0rc1‑cp38‑cp38‑win_amd64.whl from this unofficial collection of whl files and do pip install matplotlib‑3.2.0rc1‑cp38‑cp38‑win_amd64.whl in your cmd

Upvotes: 1

Victor Zuanazzi
Victor Zuanazzi

Reputation: 1974

It is a bit unclear what your problem is. It may just be that you have some packages that are not compatible. To avoid this sort of issue I can recommend the use of Anaconda: https://www.anaconda.com/

It will come with python and most basic libraries, including matplotlib. I can also recommend seaborn for professional-looking plots that do not require much code.

Upvotes: -2

Related Questions