fmotion1
fmotion1

Reputation: 531

Can't install matplotlib in a Python 3.10 venv

I've been following this tutorial:

https://code.visualstudio.com/docs/python/python-tutorial

Now when I run python -m pip install matplotlib I get an enormous amount of errors:

Collecting matplotlib
  Using cached matplotlib-3.4.3.tar.gz (37.9 MB)
  Preparing metadata (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'D:\Dev\Python\.venv\scripts\python.exe' -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\futur\\AppData\\Local\\Temp\\pip-install-ebo82l6e\\matplotlib_1d648b7683fc4253bd1e0efcfa4c8b68\\setup.py'"'"'; __file__='"'"'C:\\Users\\futur\\AppData\\Local\\Temp\\pip-install-ebo82l6e\\matplotlib_1d648b7683fc4253bd1e0efcfa4c8b68\\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\futur\AppData\Local\Temp\pip-pip-egg-info-gyrvg9v_'
       cwd: C:\Users\futur\AppData\Local\Temp\pip-install-ebo82l6e\matplotlib_1d648b7683fc4253bd1e0efcfa4c8b68\     
  Complete output (248 lines):
    ERROR: Command errored out with exit status 1:
     command: 'D:\Dev\Python\.venv\scripts\python.exe' 'D:\Dev\Python\.venv\lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\futur\AppData\Local\Temp\tmpg193i1cc'
         cwd: C:\Users\futur\AppData\Local\Temp\pip-wheel-n4amfybf\numpy_cc1bec4e42d0410f9c1a5efc1bf3f864
    Complete output (200 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\futur\AppData\Local\Temp\pip-wheel-n4amfybf\numpy_cc1bec4e42d0410f9c1a5efc1bf3f864\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:\\Dev\\Python\\.venv\\lib', 'C:\\']
      NOT AVAILABLE

    blis_info:
      libraries blis not found in ['D:\\Dev\\Python\\.venv\\lib', 'C:\\']
      NOT AVAILABLE

    openblas_info:
      libraries openblas not found in ['D:\\Dev\\Python\\.venv\\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
    Could not locate executable gfortran
    Could not locate executable f95
    customize G95FCompiler
    Could not locate executable g95
    customize IntelEM64VisualFCompiler
    customize IntelEM64TFCompiler
    Could not locate executable efort
    Could not locate executable efc
    customize PGroupFlangCompiler
    Could not locate executable flang
    don't know how to compile Fortran code on platform 'nt'
      NOT AVAILABLE

    accelerate_info:
      NOT AVAILABLE

    atlas_3_10_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries tatlas not found in ['D:\\Dev\\Python\\.venv\\lib', 'C:\\']
      NOT AVAILABLE

    atlas_3_10_blas_info:
      libraries satlas not found in ['D:\\Dev\\Python\\.venv\\lib', 'C:\\']
      NOT AVAILABLE

    atlas_blas_threads_info:
    Setting PTATLAS=ATLAS
      libraries ptf77blas,ptcblas,atlas not found in ['D:\\Dev\\Python\\.venv\\lib', 'C:\\']
      NOT AVAILABLE

    atlas_blas_info:
      libraries f77blas,cblas,atlas not found in ['D:\\Dev\\Python\\.venv\\lib', 'C:\\']
      NOT AVAILABLE

    C:\Users\futur\AppData\Local\Temp\pip-wheel-n4amfybf\numpy_cc1bec4e42d0410f9c1a5efc1bf3f864\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:\\Dev\\Python\\.venv\\lib', 'C:\\']
      NOT AVAILABLE

    C:\Users\futur\AppData\Local\Temp\pip-wheel-n4amfybf\numpy_cc1bec4e42d0410f9c1a5efc1bf3f864\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\futur\AppData\Local\Temp\pip-wheel-n4amfybf\numpy_cc1bec4e42d0410f9c1a5efc1bf3f864\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:\\Dev\\Python\\.venv\\lib', 'C:\\']
      NOT AVAILABLE

    openblas_lapack_info:
      libraries openblas not found in ['D:\\Dev\\Python\\.venv\\lib', 'C:\\']
      NOT AVAILABLE

    openblas_clapack_info:
      libraries openblas,lapack not found in ['D:\\Dev\\Python\\.venv\\lib', 'C:\\']
      NOT AVAILABLE

    flame_info:
      libraries flame not found in ['D:\\Dev\\Python\\.venv\\lib', 'C:\\']
      NOT AVAILABLE

    atlas_3_10_threads_info:
    Setting PTATLAS=ATLAS
      libraries lapack_atlas not found in D:\Dev\Python\.venv\lib
      libraries tatlas,tatlas not found in D:\Dev\Python\.venv\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:\Dev\Python\.venv\lib
      libraries satlas,satlas not found in D:\Dev\Python\.venv\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:\Dev\Python\.venv\lib
      libraries ptf77blas,ptcblas,atlas not found in D:\Dev\Python\.venv\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:\Dev\Python\.venv\lib
      libraries f77blas,cblas,atlas not found in D:\Dev\Python\.venv\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:\\Dev\\Python\\.venv\\lib', 'C:\\']
      NOT AVAILABLE

    C:\Users\futur\AppData\Local\Temp\pip-wheel-n4amfybf\numpy_cc1bec4e42d0410f9c1a5efc1bf3f864\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\futur\AppData\Local\Temp\pip-wheel-n4amfybf\numpy_cc1bec4e42d0410f9c1a5efc1bf3f864\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:\Program Files\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:\Dev\Python\.venv\lib\site-packages\setuptools\installer.py", line 75, in fetch_build_egg
      subprocess.check_call(cmd)
    File "C:\Program Files\Python310\lib\subprocess.py", line 369, in check_call
      raise CalledProcessError(retcode, cmd)
  subprocess.CalledProcessError: Command '['D:\\Dev\\Python\\.venv\\scripts\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\futur\\AppData\\Local\\Temp\\tmp94tnb4kh', '--quiet', 'numpy>=1.16']' 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\futur\AppData\Local\Temp\pip-install-ebo82l6e\matplotlib_1d648b7683fc4253bd1e0efcfa4c8b68\setup.py", line 258, in <module>
      setup(  # Finally, pass this all along to distutils to do the heavy lifting.
    File "D:\Dev\Python\.venv\lib\site-packages\setuptools\__init__.py", line 152, in setup
      _install_setup_requires(attrs)
    File "D:\Dev\Python\.venv\lib\site-packages\setuptools\__init__.py", line 147, in _install_setup_requires       
      dist.fetch_build_eggs(dist.setup_requires)
    File "D:\Dev\Python\.venv\lib\site-packages\setuptools\dist.py", line 806, in fetch_build_eggs
      resolved_dists = pkg_resources.working_set.resolve(
    File "D:\Dev\Python\.venv\lib\site-packages\pkg_resources\__init__.py", line 766, in resolve
      dist = best[req.key] = env.best_match(
    File "D:\Dev\Python\.venv\lib\site-packages\pkg_resources\__init__.py", line 1051, in best_match
      return self.obtain(req, installer)
    File "D:\Dev\Python\.venv\lib\site-packages\pkg_resources\__init__.py", line 1063, in obtain
      return installer(requirement)
    File "D:\Dev\Python\.venv\lib\site-packages\setuptools\dist.py", line 877, in fetch_build_egg
      return fetch_build_egg(self, req)
    File "D:\Dev\Python\.venv\lib\site-packages\setuptools\installer.py", line 77, in fetch_build_egg
      raise DistutilsError(str(e)) from e
  distutils.errors.DistutilsError: Command '['D:\\Dev\\Python\\.venv\\scripts\\python.exe', '-m', 'pip', '--disable-pip-version-check', 'wheel', '--no-deps', '-w', 'C:\\Users\\futur\\AppData\\Local\\Temp\\tmp94tnb4kh', '--quiet', 'numpy>=1.16']' returned non-zero exit status 1.

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

  BUILDING MATPLOTLIB
    matplotlib: yes [3.4.3]
        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]
         tests: no  [skipping due to configuration]
        macosx: no  [Mac OS-X only]

  ----------------------------------------
WARNING: Discarding https://files.pythonhosted.org/packages/21/37/197e68df384ff694f78d687a49ad39f96c67b8d75718bc61503e1676b617/matplotlib-3.4.3.tar.gz#sha256=fc4f526dfdb31c9bd6b8ca06bf9fab663ca12f3ec9cdf4496fb44bc680140318 (from https://pypi.org/simple/matplotlib/) (requires-python:>=3.7). Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.

I'm wondering if it has something to do with installing in a venv.

I took a look at pyvenv.cfg and include-system-site-packages is set to false. I'm not exactly sure what this value should be. The Scripts directory has some activation and deactivation scripts, and pip.exe, pip3.10.exe, pip3.exe, python.exe, pythonw.exe, and wheel.exe.

.venv\Lib\site-packages has the following:

distutils-precedence.pth
pip
pip-21.3.dist-info
pkg_resources
setuptools
setuptools-58.2.0.dist-info
wheel
wheel-0.37.0.dist-info
_distutils_hack
distutils-precedence.pth

Anyone know what the problem is? I'd really like to get this working.

Thanks so much for any help.

Upvotes: 1

Views: 1307

Answers (1)

buran
buran

Reputation: 14273

The latest stable version is 3.4.3. On PyPI there is no matplotlib wheel for 3.10, yet. So it try to compile from source. And for that it needs Microsoft Visual C++ 14.0 or greater.

However you can download unofficial binary from Gohlke Alternatively you can use pipwin to install it from Gohlke. Note there may still be problems with dependencies.

Of course, you can also downgrade to python3.9.

Upvotes: 2

Related Questions