0

i have a problem with installing matplotlib on my windows 10 machine

PS C:\Users\moham> pip install matplotlib
Collecting matplotlib
  Using cached matplotlib-3.4.3.tar.gz (37.9 MB)
  Preparing metadata (setup.py) ... done
Requirement already satisfied: cycler>=0.10 in c:\users\moham\appdata\local\programs\python\python310\lib\site-packages (from matplotlib) (0.11.0)
Requirement already satisfied: kiwisolver>=1.0.1 in c:\users\moham\appdata\local\programs\python\python310\lib\site-packages (from matplotlib) (1.3.2)
Requirement already satisfied: numpy>=1.16 in c:\users\moham\appdata\local\programs\python\python310\lib\site-packages (from matplotlib) (1.21.3)
Requirement already satisfied: pillow>=6.2.0 in c:\users\moham\appdata\local\programs\python\python310\lib\site-packages (from matplotlib) (8.4.0)
Requirement already satisfied: pyparsing>=2.2.1 in c:\users\moham\appdata\local\programs\python\python310\lib\site-packages (from matplotlib) (3.0.3)
Requirement already satisfied: python-dateutil>=2.7 in c:\users\moham\appdata\local\programs\python\python310\lib\site-packages (from matplotlib) (2.8.2)
Requirement already satisfied: six>=1.5 in c:\users\moham\appdata\local\programs\python\python310\lib\site-packages (from python-dateutil>=2.7->matplotlib) (1.16.0)
Building wheels for collected packages: matplotlib
  Building wheel for matplotlib (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: 'C:\Users\moham\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\moham\\AppData\\Local\\Temp\\pip-install-flrd8ddj\\matplotlib_7091154205ba4de6adb6e99636c201f9\\setup.py'"'"'; __file__='"'"'C:\\Users\\moham\\AppData\\Local\\Temp\\pip-install-flrd8ddj\\matplotlib_7091154205ba4de6adb6e99636c201f9\\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'"'"'))' bdist_wheel -d 'C:\Users\moham\AppData\Local\Temp\pip-wheel-hj9g1qjt'
       cwd: C:\Users\moham\AppData\Local\Temp\pip-install-flrd8ddj\matplotlib_7091154205ba4de6adb6e99636c201f9\
  Complete output (553 lines):

  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]

  C:\Users\moham\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\__init__.py:148: SetuptoolsDeprecationWarning: setup_requires is deprecated. Supply build dependencies using PEP 517 pyproject.toml build-requires.
    warnings.warn(
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build\lib.win-amd64-3.10
  copying lib\pylab.py -> build\lib.win-amd64-3.10

alot more lines from here but somewhere in the middle it gets to this:

 
  ----------------------------------------
  ERROR: Failed building wheel for matplotlib
  Running setup.py clean for matplotlib
Failed to build matplotlib
Installing collected packages: matplotlib
    Running setup.py install for matplotlib ... error
    ERROR: Command errored out with exit status 1:
     command: 'C:\Users\moham\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\moham\\AppData\\Local\\Temp\\pip-install-flrd8ddj\\matplotlib_7091154205ba4de6adb6e99636c201f9\\setup.py'"'"'; __file__='"'"'C:\\Users\\moham\\AppData\\Local\\Temp\\pip-install-flrd8ddj\\matplotlib_7091154205ba4de6adb6e99636c201f9\\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'"'"'))' install --record 'C:\Users\moham\AppData\Local\Temp\pip-record-wj_x0r_i\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\moham\AppData\Local\Programs\Python\Python310\Include\matplotlib'
         cwd: C:\Users\moham\AppData\Local\Temp\pip-install-flrd8ddj\matplotlib_7091154205ba4de6adb6e99636c201f9\
    Complete output (553 lines):

    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]

    C:\Users\moham\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\__init__.py:148: SetuptoolsDeprecationWarning: setup_requires is deprecated. Supply build dependencies using PEP 517 pyproject.toml build-requires.
      warnings.warn(
    running install
    C:\Users\moham\AppData\Local\Programs\Python\Python310\lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    running build
    running build_py
    creating build\lib.win-amd64-3.10
    copying lib\pylab.py -> build\lib.win-amd64-3.10

and alot more lines and ends with this:

    copying lib\matplotlib\mpl-data\images\zoom_to_rect_large.png -> build\lib.win-amd64-3.10\matplotlib\mpl-data\images    copying lib\matplotlib\mpl-data\fonts\ttf\DejaVuSansDisplay.ttf -> build\lib.win-amd64-3.10\matplotlib\mpl-data\fonts\ttf
    copying lib\matplotlib\mpl-data\fonts\afm\pagdo8a.afm -> build\lib.win-amd64-3.10\matplotlib\mpl-data\fonts\afm
    copying lib\matplotlib\mpl-data\images\matplotlib.pdf -> build\lib.win-amd64-3.10\matplotlib\mpl-data\images
    copying lib\matplotlib\backends\web_backend\css\page.css -> build\lib.win-amd64-3.10\matplotlib\backends\web_backend\css
    copying lib\matplotlib\mpl-data\fonts\ttf\STIXSizFourSymBol.ttf -> build\lib.win-amd64-3.10\matplotlib\mpl-data\fonts\ttf
    UPDATING build\lib.win-amd64-3.10\matplotlib\_version.py
    set build\lib.win-amd64-3.10\matplotlib\_version.py to '3.4.3'
    running build_ext
    error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
    Building freetype in build\freetype-2.6.1
    ----------------------------------------
ERROR: Command errored out with exit status 1: 'C:\Users\moham\AppData\Local\Programs\Python\Python310\python.exe' -u -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'C:\\Users\\moham\\AppData\\Local\\Temp\\pip-install-flrd8ddj\\matplotlib_7091154205ba4de6adb6e99636c201f9\\setup.py'"'"'; __file__='"'"'C:\\Users\\moham\\AppData\\Local\\Temp\\pip-install-flrd8ddj\\matplotlib_7091154205ba4de6adb6e99636c201f9\\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'"'"'))' install --record 'C:\Users\moham\AppData\Local\Temp\pip-record-wj_x0r_i\install-record.txt' --single-version-externally-managed --compile --install-headers 'C:\Users\moham\AppData\Local\Programs\Python\Python310\Include\matplotlib' Check the logs for full command output.
PS C:\Users\moham>

..................................................................................................................................................................................................................................................................................................................................................................................

moya20540
  • 11
  • 2

1 Answers1

0

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.

buran
  • 13,682
  • 10
  • 36
  • 61
  • can't i just install ms visual cpp 14.0 ? – moya20540 Oct 31 '21 at 12:40
  • yes, of course, that's always an option. – buran Oct 31 '21 at 13:19
  • but yo now nothing like that happened on my wsl linux machine do u know why ?and is there a reason to switch to linux for python development ? – moya20540 Nov 01 '21 at 03:37
  • See [Installing from source](https://matplotlib.org/stable/users/installing_source.html#install-from-source). It says _A C compiler is required. Typically, **on Linux, you will need gcc**, which should be installed using your distribution's package manager; on macOS, you will need xcode; **on Windows, you will need Visual Studio 2015 or later**._ I guess you had everything required already installed. – buran Nov 01 '21 at 05:23
  • thank u so much man u cleared up a lot of stuff. – moya20540 Nov 01 '21 at 13:31