-1

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

5
  • Please post your codes and errors. Commented Nov 4, 2019 at 11:59
  • 1
    On Windows, sometimes your environment is not configured correctly build packages. In such cases, try to get the whl file from here: lfd.uci.edu/~gohlke/pythonlibs Commented Nov 4, 2019 at 12:05
  • Thanks MrFuppes,but what do I do with the whl file? Commented Nov 4, 2019 at 12:24
  • stackoverflow.com/search?q=%5Bpython%5D+how+to+install+whl+file Commented Nov 4, 2019 at 13:33
  • You can install whl files with pip install PATHTOFILE.whl Commented Nov 4, 2019 at 14:59

2 Answers 2

1

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
Sign up to request clarification or add additional context in comments.

Comments

-2

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.

1 Comment

Thanks Victor. I already have anaconda installed with python. However, I need to run python scripts separately in power BI, and therefore need to install it on my cmd

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.