Can't install matplotlib : fatal error C1083: Cannot open include file: 'ft2build.h': No such file or directory

Viewed 1415

I'm trying to install the matplotlib module but when I try to do so I get an error, that being pretty big but it seems to be due to a missing file, ft2build.h

What can I do to fix this?

Here is the error code I get (I've had to remove part of the error message as it was too big, I removed the part where files were copied and some created):

ERROR: Command errored out with exit status 1:
     command: 'C:\Users\Maca\AppData\Local\Programs\Python\Python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Maca\\AppData\\Local\\Temp\\pip-install-8fraia6a\\matplotlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\Maca\\AppData\\Local\\Temp\\pip-install-8fraia6a\\matplotlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Maca\AppData\Local\Temp\pip-record-1miy2gd_\install-record.txt' --single-version-externally-managed --compile
         cwd: C:\Users\Maca\AppData\Local\Temp\pip-install-8fraia6a\matplotlib\
    Complete output (505 lines):
    ================================================================================
    Edit setup.cfg to change the build options

    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]

    OPTIONAL SUBPACKAGES
     sample_data: yes [installing]
           tests: no  [skipping due to configuration]

    OPTIONAL BACKEND EXTENSIONS
             agg: yes [installing]
           tkagg: yes [installing; run-time loading from Python Tcl/Tk]
          macosx: no  [Mac OS-X only]

    OPTIONAL PACKAGE DATA
            dlls: no  [skipping due to configuration]


    UPDATING build\lib.win32-3.8\matplotlib\_version.py
    set build\lib.win32-3.8\matplotlib\_version.py to '3.1.1'
    running build_ext
    building 'matplotlib.ft2font' extension
    creating build\temp.win32-3.8
    creating build\temp.win32-3.8\Release
    creating build\temp.win32-3.8\Release\src
    D:\Program Files\Microsoft Visual Studio\VC\Tools\MSVC\14.15.26726\bin\HostX86\x86\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MD -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 -IC:\Users\Maca\AppData\Local\Programs\Python\Python38-32\lib\site-packages\numpy\core\include -IC:\Users\Maca\AppData\Local\Programs\Python\Python38-32\include -IC:\Users\Maca\AppData\Local\Programs\Python\Python38-32\include "-ID:\Program Files\Microsoft Visual Studio\VC\Tools\MSVC\14.15.26726\ATLMFC\include" "-ID:\Program Files\Microsoft Visual Studio\VC\Tools\MSVC\14.15.26726\include" "-IC:\Program Files (x86)\Windows Kits\NETFXSDK\4.6.1\include\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\ucrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\shared" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\um" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\winrt" "-IC:\Program Files (x86)\Windows Kits\10\include\10.0.17134.0\cppwinrt" /Tcsrc/checkdep_freetype2.c /Fobuild\temp.win32-3.8\Release\src/checkdep_freetype2.obj
    checkdep_freetype2.c
    src/checkdep_freetype2.c(1): fatal error C1083: Cannot open include file: 'ft2build.h': No such file or directory
    error: command 'D:\\Program Files\\Microsoft Visual Studio\\VC\\Tools\\MSVC\\14.15.26726\\bin\\HostX86\\x86\\cl.exe' failed with exit status 2
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\Maca\AppData\Local\Programs\Python\Python38-32\python.exe' -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\Maca\\AppData\\Local\\Temp\\pip-install-8fraia6a\\matplotlib\\setup.py'"'"'; __file__='"'"'C:\\Users\\Maca\\AppData\\Local\\Temp\\pip-install-8fraia6a\\matplotlib\\setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record 'C:\Users\Maca\AppData\Local\Temp\pip-record-1miy2gd_\install-record.txt' --single-version-externally-managed --compile Check the logs for full command output.
2 Answers

Download your file to a folder on your C drive. In windows CMD prompt as Administrator navigate you your path using cd.. or cd wheels (in my case I saved the file to c:\Wheels) then type pip install YourFilename.whl

At the time the version of python I installed was quite new, therefore didnt quite have the support for the module at this point. As pointed out by Talha Junaid. I have also encountered a similar issue with multiple other modules from time to time, though not necessarily in this form of error.

Related