Python 3.10 的 Matplotlib 安装问题

Posted

技术标签:

【中文标题】Python 3.10 的 Matplotlib 安装问题【英文标题】:Matplotlib Installation issues with Python 3.10 【发布时间】:2021-11-29 17:21:18 【问题描述】:

首先,我不认为这是matplotlib installation issue python 3这个的重复帖子 问题与刚刚发布的 matplotlib 和 Python 3.10 有关。

我的问题

我在使用Python 3.10. 安装 matplotlib 时遇到问题Python 3.9.6 没有这些问题。在安装 matplotlib 时,我引用了official instructions 并使用了以下命令:

python -m pip install -U matplotlib

然后我收到了这个很长的错误信息:

WARNING: Discarding https://files.pythonhosted.org/packages/7d/d4/e4c40c62cd8608ca09f0684e64139c56512e195f2351ac41a472d4dc8b38/matplotlib-3.3.0.tar.gz#sha256=24e8db94948019d531ce0bcd637ac24b1c8f6744ac86d2aa0eb6dbaeb1386f82 (from https://pypi.org/simple/matplotlib/) (requires-python:>=3.6). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  Using cached matplotlib-3.2.2.tar.gz (40.3 MB)
    ERROR: Command errored out with exit status 1:
     command: 'D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\Scripts\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\serap\\AppData\\Local\\Temp\\pip-install-z6821kj4\\matplotlib_dd551371f0ba45a889cb056fa0e24291\\setup.py'"'"'; __file__='"'"'C:\\Users\\serap\\AppData\\Local\\Temp\\pip-install-z6821kj4\\matplotlib_dd551371f0ba45a889cb056fa0e24291\\setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base 'C:\Users\serap\AppData\Local\Temp\pip-pip-egg-info-iiicui1u'
         cwd: C:\Users\serap\AppData\Local\Temp\pip-install-z6821kj4\matplotlib_dd551371f0ba45a889cb056fa0e24291\
    Complete output (277 lines):
    WARNING: The wheel package is not available.
      ERROR: Command errored out with exit status 1:
       command: 'D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\Scripts\python.exe' 'D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\serap\AppData\Local\Temp\tmpinu_l323'
           cwd: C:\Users\serap\AppData\Local\Temp\pip-wheel-99zdamg9\numpy_e42242834a6f47f2b97c9e7786bac5de
      Complete output (225 lines):
      setup.py:63: RuntimeWarning: NumPy 1.21.2 may not yet support Python 3.10.
        warnings.warn(
      Running from numpy source directory.
      C:\Users\serap\AppData\Local\Temp\pip-wheel-99zdamg9\numpy_e42242834a6f47f2b97c9e7786bac5de\tools\cythonize.py:69: DeprecationWarning: The distutils package is deprecated and slated for removal in Python 3.12. Use setuptools or check PEP 632 for potential alternatives
        from distutils.version import LooseVersion
      Processing numpy/random\_bounded_integers.pxd.in
      Processing numpy/random\bit_generator.pyx
      Processing numpy/random\mtrand.pyx
      Processing numpy/random\_bounded_integers.pyx.in
      Processing numpy/random\_common.pyx
      Processing numpy/random\_generator.pyx
      Processing numpy/random\_mt19937.pyx
      Processing numpy/random\_pcg64.pyx
      Processing numpy/random\_philox.pyx
      Processing numpy/random\_sfc64.pyx
      Cythonizing sources
      blas_opt_info:
      blas_mkl_info:
      No module named 'numpy.distutils._msvccompiler' in numpy.distutils; trying from distutils
      customize MSVCCompiler
        libraries mkl_rt not found in ['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\lib', 'C:\\']
        NOT AVAILABLE

      blis_info:
        libraries blis not found in ['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\lib', 'C:\\']
        NOT AVAILABLE

      openblas_info:
        libraries openblas not found in ['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\lib', 'C:\\']
      get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
      customize GnuFCompiler
      Could not locate executable g77
      Could not locate executable f77
      customize IntelVisualFCompiler
      Could not locate executable ifort
      Could not locate executable ifl
      customize AbsoftFCompiler
      Could not locate executable f90
      customize CompaqVisualFCompiler
      Could not locate executable DF
      customize IntelItaniumVisualFCompiler
      Could not locate executable efl
      customize Gnu95FCompiler
      Found executable C:\Program Files (x86)\mingw-w64\mingw32\bin\gfortran.exe
      Using built-in specs.
      COLLECT_GCC=C:\Program Files (x86)\mingw-w64\mingw32\bin\gfortran.exe
      COLLECT_LTO_WRAPPER=C:/Program\ Files\ (x86)/mingw-w64/mingw32/bin/../libexec/gcc/i686-w64-mingw32/8.1.0/lto-wrapper.exe
      Target: i686-w64-mingw32
      Configured with: ../../../src/gcc-8.1.0/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-sjlj-exceptions --with-dwarf2 --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=i686 --with-tune=generic --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-pkgversion='i686-posix-dwarf-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/include -I/c/mingw810/prerequisites/i686-zlib-static/include -I/c/mingw810/prerequisites/i686-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/include -I/c/mingw810/prerequisites/i686-zlib-static/include -I/c/mingw810/prerequisites/i686-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/include -I/c/mingw810/prerequisites/i686-zlib-static/include -I/c/mingw810/prerequisites/i686-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/lib -L/c/mingw810/prerequisites/i686-zlib-static/lib -L/c/mingw810/prerequisites/i686-w64-mingw32-static/lib -Wl,--large-address-aware'
      Thread model: posix
      gcc version 8.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project)
        NOT AVAILABLE

      accelerate_info:
        NOT AVAILABLE

      atlas_3_10_blas_threads_info:
      Setting PTATLAS=ATLAS
        libraries tatlas not found in ['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\lib', 'C:\\']
        NOT AVAILABLE

      atlas_3_10_blas_info:
        libraries satlas not found in ['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\lib', 'C:\\']
        NOT AVAILABLE

      atlas_blas_threads_info:
      Setting PTATLAS=ATLAS
        libraries ptf77blas,ptcblas,atlas not found in ['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\lib', 'C:\\']
        NOT AVAILABLE

      atlas_blas_info:
        libraries f77blas,cblas,atlas not found in ['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\lib', 'C:\\']
        NOT AVAILABLE

      C:\Users\serap\AppData\Local\Temp\pip-wheel-99zdamg9\numpy_e42242834a6f47f2b97c9e7786bac5de\numpy\distutils\system_info.py:2026: UserWarning:
          Optimized (vendor) Blas libraries are not found.
          Falls back to netlib Blas library which has worse performance.
          A better performance should be easily gained by switching
          Blas library.
        if self._calc_info(blas):
      blas_info:
        libraries blas not found in ['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\lib', 'C:\\']
        NOT AVAILABLE

      C:\Users\serap\AppData\Local\Temp\pip-wheel-99zdamg9\numpy_e42242834a6f47f2b97c9e7786bac5de\numpy\distutils\system_info.py:2026: UserWarning:
          Blas (http://www.netlib.org/blas/) libraries not found.
          Directories to search for the libraries can be specified in the
          numpy/distutils/site.cfg file (section [blas]) or by setting
          the BLAS environment variable.
        if self._calc_info(blas):
      blas_src_info:
        NOT AVAILABLE

      C:\Users\serap\AppData\Local\Temp\pip-wheel-99zdamg9\numpy_e42242834a6f47f2b97c9e7786bac5de\numpy\distutils\system_info.py:2026: UserWarning:
          Blas (http://www.netlib.org/blas/) sources not found.
          Directories to search for the sources can be specified in the
          numpy/distutils/site.cfg file (section [blas_src]) or by setting
          the BLAS_SRC environment variable.
        if self._calc_info(blas):
        NOT AVAILABLE

      non-existing path in 'numpy\\distutils': 'site.cfg'
      lapack_opt_info:
      lapack_mkl_info:
        libraries mkl_rt not found in ['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\lib', 'C:\\']
        NOT AVAILABLE

      openblas_lapack_info:
        libraries openblas not found in ['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\lib', 'C:\\']
      get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
      customize GnuFCompiler
      customize IntelVisualFCompiler
      customize AbsoftFCompiler
      customize CompaqVisualFCompiler
      customize IntelItaniumVisualFCompiler
      customize Gnu95FCompiler
      Using built-in specs.
      COLLECT_GCC=C:\Program Files (x86)\mingw-w64\mingw32\bin\gfortran.exe
      COLLECT_LTO_WRAPPER=C:/Program\ Files\ (x86)/mingw-w64/mingw32/bin/../libexec/gcc/i686-w64-mingw32/8.1.0/lto-wrapper.exe
      Target: i686-w64-mingw32
      Configured with: ../../../src/gcc-8.1.0/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-sjlj-exceptions --with-dwarf2 --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=i686 --with-tune=generic --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-pkgversion='i686-posix-dwarf-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/include -I/c/mingw810/prerequisites/i686-zlib-static/include -I/c/mingw810/prerequisites/i686-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/include -I/c/mingw810/prerequisites/i686-zlib-static/include -I/c/mingw810/prerequisites/i686-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/include -I/c/mingw810/prerequisites/i686-zlib-static/include -I/c/mingw810/prerequisites/i686-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/lib -L/c/mingw810/prerequisites/i686-zlib-static/lib -L/c/mingw810/prerequisites/i686-w64-mingw32-static/lib -Wl,--large-address-aware'
      Thread model: posix
      gcc version 8.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project)
        NOT AVAILABLE

      openblas_clapack_info:
        libraries openblas,lapack not found in ['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\lib', 'C:\\']
      get_default_fcompiler: matching types: '['gnu', 'intelv', 'absoft', 'compaqv', 'intelev', 'gnu95', 'g95', 'intelvem', 'intelem', 'flang']'
      customize GnuFCompiler
      customize IntelVisualFCompiler
      customize AbsoftFCompiler
      customize CompaqVisualFCompiler
      customize IntelItaniumVisualFCompiler
      customize Gnu95FCompiler
      Using built-in specs.
      COLLECT_GCC=C:\Program Files (x86)\mingw-w64\mingw32\bin\gfortran.exe
      COLLECT_LTO_WRAPPER=C:/Program\ Files\ (x86)/mingw-w64/mingw32/bin/../libexec/gcc/i686-w64-mingw32/8.1.0/lto-wrapper.exe
      Target: i686-w64-mingw32
      Configured with: ../../../src/gcc-8.1.0/configure --host=i686-w64-mingw32 --build=i686-w64-mingw32 --target=i686-w64-mingw32 --prefix=/mingw32 --with-sysroot=/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-sjlj-exceptions --with-dwarf2 --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=i686 --with-tune=generic --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/i686-w64-mingw32-static --with-pkgversion='i686-posix-dwarf-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/include -I/c/mingw810/prerequisites/i686-zlib-static/include -I/c/mingw810/prerequisites/i686-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/include -I/c/mingw810/prerequisites/i686-zlib-static/include -I/c/mingw810/prerequisites/i686-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/include -I/c/mingw810/prerequisites/i686-zlib-static/include -I/c/mingw810/prerequisites/i686-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/i686-810-posix-dwarf-rt_v6-rev0/mingw32/opt/lib -L/c/mingw810/prerequisites/i686-zlib-static/lib -L/c/mingw810/prerequisites/i686-w64-mingw32-static/lib -Wl,--large-address-aware'
      Thread model: posix
      gcc version 8.1.0 (i686-posix-dwarf-rev0, Built by MinGW-W64 project)
        NOT AVAILABLE

      flame_info:
        libraries flame not found in ['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\lib', 'C:\\']
        NOT AVAILABLE

      atlas_3_10_threads_info:
      Setting PTATLAS=ATLAS
        libraries lapack_atlas not found in D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib
        libraries tatlas,tatlas not found in D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib
        libraries lapack_atlas not found in C:\
        libraries tatlas,tatlas not found in C:\
      <class 'numpy.distutils.system_info.atlas_3_10_threads_info'>
        NOT AVAILABLE

      atlas_3_10_info:
        libraries lapack_atlas not found in D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib
        libraries satlas,satlas not found in D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib
        libraries lapack_atlas not found in C:\
        libraries satlas,satlas not found in C:\
      <class 'numpy.distutils.system_info.atlas_3_10_info'>
        NOT AVAILABLE

      atlas_threads_info:
      Setting PTATLAS=ATLAS
        libraries lapack_atlas not found in D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib
        libraries ptf77blas,ptcblas,atlas not found in D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib
        libraries lapack_atlas not found in C:\
        libraries ptf77blas,ptcblas,atlas not found in C:\
      <class 'numpy.distutils.system_info.atlas_threads_info'>
        NOT AVAILABLE

      atlas_info:
        libraries lapack_atlas not found in D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib
        libraries f77blas,cblas,atlas not found in D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib
        libraries lapack_atlas not found in C:\
        libraries f77blas,cblas,atlas not found in C:\
      <class 'numpy.distutils.system_info.atlas_info'>
        NOT AVAILABLE

      lapack_info:
        libraries lapack not found in ['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\lib', 'C:\\']
        NOT AVAILABLE

      C:\Users\serap\AppData\Local\Temp\pip-wheel-99zdamg9\numpy_e42242834a6f47f2b97c9e7786bac5de\numpy\distutils\system_info.py:1858: UserWarning:
          Lapack (http://www.netlib.org/lapack/) libraries not found.
          Directories to search for the libraries can be specified in the
          numpy/distutils/site.cfg file (section [lapack]) or by setting
          the LAPACK environment variable.
        return getattr(self, '_calc_info_'.format(name))()
      lapack_src_info:
        NOT AVAILABLE

      C:\Users\serap\AppData\Local\Temp\pip-wheel-99zdamg9\numpy_e42242834a6f47f2b97c9e7786bac5de\numpy\distutils\system_info.py:1858: UserWarning:
          Lapack (http://www.netlib.org/lapack/) sources not found.
          Directories to search for the sources can be specified in the
          numpy/distutils/site.cfg file (section [lapack_src]) or by setting
          the LAPACK_SRC environment variable.
        return getattr(self, '_calc_info_'.format(name))()
        NOT AVAILABLE

      numpy_linalg_lapack_lite:
        FOUND:
          language = c
          define_macros = [('HAVE_BLAS_ILP64', None), ('BLAS_SYMBOL_SUFFIX', '64_')]

      Warning: attempted relative import with no known parent package
      C:\Users\serap\AppData\Local\Programs\Python\Python310\lib\distutils\dist.py:274: UserWarning: Unknown distribution option: 'define_macros'
        warnings.warn(msg)
      running bdist_wheel
      running build
      running config_cc
      unifing config_cc, config, build_clib, build_ext, build commands --compiler options
      running config_fc
      unifing config_fc, config, build_clib, build_ext, build commands --fcompiler options
      running build_src
      build_src
      building py_modules sources
      creating build
      creating build\src.win-amd64-3.10
      creating build\src.win-amd64-3.10\numpy
      creating build\src.win-amd64-3.10\numpy\distutils
      building library "npymath" sources
      error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/
      ----------------------------------------
      ERROR: Failed building wheel for numpy
    ERROR: Failed to build one or more wheels
    Traceback (most recent call last):
      File "D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib\site-packages\setuptools\installer.py", line 75, in fetch_build_egg
        subprocess.check_call(cmd)
      File "C:\Users\serap\AppData\Local\Programs\Python\Python310\lib\subprocess.py", line 369, in check_call
        raise CalledProcessError(retcode, cmd)
    subprocess.CalledProcessError: Command '['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\Scripts\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\serap\\AppData\\Local\\Temp\\tmpniofxxvj', '--quiet', 'numpy>=1.11']' returned non-zero exit status 1.

    The above exception was the direct cause of the following exception:

    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "C:\Users\serap\AppData\Local\Temp\pip-install-z6821kj4\matplotlib_dd551371f0ba45a889cb056fa0e24291\setup.py", line 236, in <module>
        setup(
      File "D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib\site-packages\setuptools\__init__.py", line 152, in setup
        _install_setup_requires(attrs)
      File "D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib\site-packages\setuptools\__init__.py", line 147, in _install_setup_requires
        dist.fetch_build_eggs(dist.setup_requires)
      File "D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib\site-packages\setuptools\dist.py", line 785, in fetch_build_eggs
        resolved_dists = pkg_resources.working_set.resolve(
      File "D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib\site-packages\pkg_resources\__init__.py", line 766, in resolve
        dist = best[req.key] = env.best_match(
      File "D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib\site-packages\pkg_resources\__init__.py", line 1051, in best_match
        return self.obtain(req, installer)
      File "D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib\site-packages\pkg_resources\__init__.py", line 1063, in obtain
        return installer(requirement)
      File "D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib\site-packages\setuptools\dist.py", line 844, in fetch_build_egg
        return fetch_build_egg(self, req)
      File "D:\GitHub\CodexGigas\PythonCrashCourse\chapter15\.project-env\lib\site-packages\setuptools\installer.py", line 77, in fetch_build_egg
        raise DistutilsError(str(e)) from e
    distutils.errors.DistutilsError: Command '['D:\\GitHub\\CodexGigas\\PythonCrashCourse\\chapter15\\.project-env\\Scripts\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\serap\\AppData\\Local\\Temp\\tmpniofxxvj', '--quiet', 'numpy>=1.11']' returned non-zero exit status 1.

    Edit setup.cfg to change the build options; suppress output with --quiet.

    BUILDING MATPLOTLIB
      matplotlib: yes [3.2.2]
          python: yes [3.10.0 (tags/v3.10.0:b494f59, Oct  4 2021, 19:00:18) [MSC
                      v.1929 64 bit (AMD64)]]
        platform: yes [win32]
     sample_data: yes [installing]
           tests: no  [skipping due to configuration]
             agg: yes [installing]
           tkagg: yes [installing; run-time loading from Python Tcl/Tk]
          macosx: no  [Mac OS-X only]

    ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/9c/4b/06f4aa9bef6b5e4f177881b4dedd94faa6e7cb3d95dfaeaa8a1a8b541095/matplotlib-3.2.2.tar.gz#sha256=3d77a6630d093d74cbbfebaa0571d00790966be1ed204e4a8239f5cbd6835c5d (from https://pypi.org/simple/matplotlib/) (requires-python:>=3.6). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
  Using cached matplotlib-3.2.1.tar.gz (40.3 MB)

然后,在错误消息之后,pip 尝试再次安装 matplotlib,但失败并重复相同的错误消息;好像它被困在一个连续的循环中,直到我结束它! 同样,Python 3.9.6 没有这个问题,因此,我假设这可能与 Python 的新版本有关。

我也尝试了以下命令

pip install matplotlib python3 install matplotlib

我想要的解决方案

    我想知道为什么会收到错误消息 我想安装和使用matplotlibPython 3.10 ---> 简单的方法

像我five-years old 一样向我解释我在这里做错了什么?

【问题讨论】:

你试过pip install matplotlib --user吗? 还有一些依赖项还没有被移植。 我刚试过pip install matplotlib --user,我得到了同样的错误信息。 我使用 anaconda,它告诉我所有未满足的依赖项。我周五查了,但不记得哪些包没有更新,我在手机上 查看我对这个question 的评论,有同样的问题。 matplotlib 需要 python &lt;3.10 【参考方案1】:

不完全确定,但我遇到了同样的问题。经过一些挖掘和测试,我想我发现 Matplotlib 和 pylab 与 python3.10 不兼容。目前我将 python3.9 和 3.10 一起使用,所以每当我使用 matplotlib、numpy 或 pylab 时,我只使用 3.9 版本。

【讨论】:

以上是关于Python 3.10 的 Matplotlib 安装问题的主要内容,如果未能解决你的问题,请参考以下文章

在 Windows10 上的 Python 3.10 中安装 scipy 时出错

利用Conda尝鲜Python 3.10

Python 3.10 中的 event_loops 问题

有没有办法匹配 Python ≥ 3.10 中的不等式?

Pip 不适用于 Ubuntu 上的 Python 3.10

Python 3.10 不支持 pygame 吗?