Problems compilling Matplotlib in Ubuntu 20

I cloned my own fork of the MatPlotLib repository, as indicated in the Contributing documentation, created a virtual environment in the project and when I run pip install -e . I get the following output:

Obtaining file:///home/my_home/matplotlib
Requirement already satisfied: cycler>=0.10 in ./venv/lib/python3.9/site-packages (from matplotlib==3.3.4+2316.g99d19f7ff) (0.10.0)
Requirement already satisfied: kiwisolver>=1.0.1 in ./venv/lib/python3.9/site-packages (from matplotlib==3.3.4+2316.g99d19f7ff) (1.3.1)
Requirement already satisfied: numpy>=1.16 in ./venv/lib/python3.9/site-packages (from matplotlib==3.3.4+2316.g99d19f7ff) (1.20.0)
Requirement already satisfied: pillow>=6.2.0 in ./venv/lib/python3.9/site-packages (from matplotlib==3.3.4+2316.g99d19f7ff) (8.1.0)
Requirement already satisfied: pyparsing>=2.2.1 in ./venv/lib/python3.9/site-packages (from matplotlib==3.3.4+2316.g99d19f7ff) (2.4.7)
Requirement already satisfied: python-dateutil>=2.7 in ./venv/lib/python3.9/site-packages (from matplotlib==3.3.4+2316.g99d19f7ff) (2.8.1)
Requirement already satisfied: six in ./venv/lib/python3.9/site-packages (from cycler>=0.10->matplotlib==3.3.4+2316.g99d19f7ff) (1.15.0)
Installing collected packages: matplotlib
  Running setup.py develop for matplotlib
    ERROR: Command errored out with exit status 1:
     command: /home/my_home/matplotlib/venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/my_home/matplotlib/setup.py'"'"'; __file__='"'"'/home/my_home/matplotlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
         cwd: /home/my_home/matplotlib/
    Complete output (28 lines):
    WARNING: The wheel package is not available.
    
    Edit setup.cfg to change the build options; suppress output with --quiet.
    
    BUILDING MATPLOTLIB
      matplotlib: yes [3.3.4+2316.g99d19f7ff]
          python: yes [3.9.1 (default, Feb  4 2021, 17:55:50)  [GCC 5.4.0 20160609]]
        platform: yes [linux]
           tests: no  [skipping due to configuration]
          macosx: no  [Mac OS-X only]
    
    running develop
    running egg_info
    writing lib/matplotlib.egg-info/PKG-INFO
    writing dependency_links to lib/matplotlib.egg-info/dependency_links.txt
    writing namespace_packages to lib/matplotlib.egg-info/namespace_packages.txt
    writing requirements to lib/matplotlib.egg-info/requires.txt
    writing top-level names to lib/matplotlib.egg-info/top_level.txt
    reading manifest file 'lib/matplotlib.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no previously-included files matching '*' found under directory 'lib/matplotlib/backends/web_backend/node_modules'
    writing manifest file 'lib/matplotlib.egg-info/SOURCES.txt'
    running build_ext
    gcc-5 -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/home/my_home/matplotlib/venv/include -I/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.1_9/include/python3.9 -c /tmp/tmpukefrkl3.cpp -o tmp/tmpukefrkl3.o -fvisibility=hidden
    gcc-5 -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -I/home/my_home/matplotlib/venv/include -I/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.1_9/include/python3.9 -c /tmp/tmpv7jal0u4.cpp -o tmp/tmpv7jal0u4.o -fvisibility-inlines-hidden
    building 'matplotlib.backends._backend_agg' extension
    gcc-5 -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -O3 -Wall -fPIC -DPY_ARRAY_UNIQUE_SYMBOL=MPL_matplotlib_backends__backend_agg_ARRAY_API -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -D__STDC_FORMAT_MACROS=1 -DFREETYPE_BUILD_TYPE=local -Ibuild/freetype-2.6.1/include -Iextern/agg24-svn/include -I/home/my_home/matplotlib/venv/lib/python3.9/site-packages/numpy/core/include -I/home/my_home/matplotlib/venv/include -I/home/linuxbrew/.linuxbrew/Cellar/python@3.9/3.9.1_9/include/python3.9 -c extern/agg24-svn/src/agg_bezier_arc.cpp -o build/temp.linux-x86_64-3.9/extern/agg24-svn/src/agg_bezier_arc.o
    error: command 'gcc-5' failed: No such file or directory
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/my_home/matplotlib/venv/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/my_home/matplotlib/setup.py'"'"'; __file__='"'"'/home/my_home/matplotlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

Did anyone found this error before? How can I fix it?

Thanks

The error message

    error: command 'gcc-5' failed: No such file or directory

is telling you that it is expecting you to have version 5 of the GCC compiler installed. Normally the advice would be to install the corresponding Ubuntu package using

    sudo apt install gcc-5

However, gcc-5 is old and hasn’t been available in Ubuntu since 18.04 (see Ubuntu – Package Search Results -- gcc-5). On my Ubuntu 20.10 install there are system packages available for gcc-7 through to gcc-10.

Your virtual environment looks suspect to me. This line

      python: yes [3.9.1 (default, Feb  4 2021, 17:55:50)  [GCC 5.4.0 20160609]]

shows that it has python 3.9.1, which is very recent, but it is compiled using GCC 5.4.0 which dates from 2016. If I create a fresh virtual environment on my Ubuntu 20.10 machine I get

    Python 3.8.6 (default, Sep 25 2020, 09:36:53) 
    [GCC 10.2.0] on linux

which is a slightly older version of python but a very recent GCC version.

I would delete your virtual environment and create a new one. Perhaps there were some problems building the Python packages and these have now been resolved, hence my different results. The other possibility is that you are running on some unusual hardware.

Ian