0

I have downloaded Python 3.7 and was using my terminal to install matplotlib onto my Mac OS. I tried:

pip3 install matplotlib

However, I faced the following error:

        ERROR: Command errored out with exit status 1:
     command: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/fm/gp4lphn1231f22hp_kzh82rw0000gn/T/pip-install-n_oqiwm0/matplotlib/setup.py'"'"'; __file__='"'"'/private/var/folders/fm/gp4lphn1231f22hp_kzh82rw0000gn/T/pip-install-n_oqiwm0/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 /private/var/folders/fm/gp4lphn1231f22hp_kzh82rw0000gn/T/pip-record-_jw4chgf/install-record.txt --single-version-externally-managed --compile
         cwd: /private/var/folders/fm/gp4lphn1231f22hp_kzh82rw0000gn/T/pip-install-n_oqiwm0/matplotlib/
    Complete output (506 lines):
    ================================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
      matplotlib: yes [3.1.1]
          python: yes [3.8.0 (v3.8.0:fa919fdf25, Oct 14 2019, 10:23:27)  [Clang 6.0
                      (clang-600.0.57)]]
        platform: yes [darwin]

    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: yes [installing, darwin]

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

    UPDATING build/lib.macosx-10.9-x86_64-3.8/matplotlib/_version.py
    set build/lib.macosx-10.9-x86_64-3.8/matplotlib/_version.py to '3.1.1'
    running build_ext
    building 'matplotlib.ft2font' extension
    creating build/temp.macosx-10.9-x86_64-3.8
    creating build/temp.macosx-10.9-x86_64-3.8/src
    gcc -Wno-unused-result -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -arch x86_64 -g -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/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages/numpy/core/include -I/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -c src/checkdep_freetype2.c -o build/temp.macosx-10.9-x86_64-3.8/src/checkdep_freetype2.o
    src/checkdep_freetype2.c:1:10: fatal error: 'ft2build.h' file not found
    #include <ft2build.h>
             ^~~~~~~~~~~~
    1 error generated.
    error: command 'gcc' failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3.8 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/fm/gp4lphn1231f22hp_kzh82rw0000gn/T/pip-install-n_oqiwm0/matplotlib/setup.py'"'"'; __file__='"'"'/private/var/folders/fm/gp4lphn1231f22hp_kzh82rw0000gn/T/pip-install-n_oqiwm0/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 /private/var/folders/fm/gp4lphn1231f22hp_kzh82rw0000gn/T/pip-record-_jw4chgf/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

I do not know why it will not install. I've tried both 3.7 and 3.8; however, nothing seems to be working.

  • It probably has something to do with your compiler. What compiler do you have? – Jack Hanson Nov 04 '19 at 17:20
  • Can you please copy paste a bit more of the error logs you see on you terminal? – nitin3685 Nov 04 '19 at 17:22
  • Best don't try to install matplotlib 3.1 on python 3.8 for now. There are all kinds of problems that originate from the need to build it from source. Use python 3.7 for the time being, preventing to compile anything. – ImportanceOfBeingErnest Nov 04 '19 at 17:33
  • Possible duplicate of [Error in installing Matplotlib : fatal error C1083](https://stackoverflow.com/questions/58455888/error-in-installing-matplotlib-fatal-error-c1083) – phd Nov 04 '19 at 17:53

1 Answers1

0

You're lacking a C compiler, which is required to compile Matplotlib from scratch.

In general, Matplotlib and many other more complex libraries are distributed as wheels, in binary form.

However, you mention you're using Python 3.8, which is very recent. Unfortunately at the time of writing there are no wheels for the latest release of Matplotlib for Python 3.8.

They do exist for the latest pre-release version 3.2.0a1, though.

If you're willing to try out that version,

pip3 install --pre matplotlib==3.2.0a1

or just install Python 3.7 instead.

AKX
  • 152,115
  • 15
  • 115
  • 172