Python 安装旧版matplotlib导致freetype和png错误

Python installing old version of matplotlib results in freetype and png error

我正在尝试安装以下软件包:https://pypi.org/project/autocluster/

但是,它看起来需要使用 matplotlib==3.0.3,因为当我尝试安装它时出现以下错误:

我已经安装了更新版本的 matplotlib,我也尝试安装旧版本,但它的核心是使用 3.0.3 构建新包。如何正确安装此版本或绕过该问题?

pip3 install matplotlib==3.0.3 -U
Looking in indexes: https://pypi.org/simple, https://1205d49dc47b4644d672f57e74f850e6342693e3f0b8cf0b:****@packagecloud.io/agrible/internal/pypi/simple
Collecting matplotlib==3.0.3
  Using cached matplotlib-3.0.3.tar.gz (36.6 MB)
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-cbungo0j/matplotlib/setup.py'"'"'; __file__='"'"'/tmp/pip-install-cbungo0j/matplotlib/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-cbungo0j/matplotlib/pip-egg-info
         cwd: /tmp/pip-install-cbungo0j/matplotlib/
    Complete output (51 lines):
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-install-cbungo0j/matplotlib/setup.py", line 225, in <module>
        msg = pkg.install_help_msg()
      File "/tmp/pip-install-cbungo0j/matplotlib/setupext.py", line 650, in install_help_msg
        release = platform.linux_distribution()[0].lower()
    AttributeError: module 'platform' has no attribute 'linux_distribution'
    IMPORTANT WARNING:
        pkg-config is not installed.
        matplotlib may not be able to find some of its dependencies
    ============================================================================
    Edit setup.cfg to change the build options

    BUILDING MATPLOTLIB
                matplotlib: yes [3.0.3]
                    python: yes [3.8.2 (default, Apr 27 2020, 15:53:34)  [GCC
                            9.3.0]]
                  platform: yes [linux]

    REQUIRED DEPENDENCIES AND EXTENSIONS
                     numpy: yes [version 1.18.5]
          install_requires: yes [handled by setuptools]
                    libagg: yes [pkg-config information for 'libagg' could not
                            be found. Using local copy.]
                  freetype: no  [The C/C++ header for freetype2 (ft2build.h)
                            could not be found.  You may need to install the
                            development package.]
                       png: no  [pkg-config information for 'libpng' could not
                            be found.]
                     qhull: yes [pkg-config information for 'libqhull' could not
                            be found. Using local copy.]

    OPTIONAL SUBPACKAGES
               sample_data: yes [installing]
                  toolkits: yes [installing]
                     tests: no  [skipping due to configuration]
            toolkits_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]
                 windowing: no  [Microsoft Windows only]

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

    ============================================================================
                            * The following required packages can not be built:
                            * freetype, png
    ----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

请注意,我正在使用我的 windows 机器在 Ubuntu 上安装它。

matplotlib 3.0.3 provides wheels 适用于 Python 3.5-3.7 但不适用于 3.8,因此 pip 尝试从源构建但失败了。

使用Python 3.7。或者 install dependencies and build from sources.