Search code examples
pythonwindowspipscipy

Failed scipy install using pip on Windows [Preparing metadata (pyproject.toml) did not run successfully]


I managed to install a few popular python packages using pip in Windows, (more speicifically using the command py -m pip install <packagename>).

Packages like numpy, pandas, matplotlib, pyqt5, etc. had no problem installing, but some packages like scipy and scikit-learn give errors.

Collecting scipy
  Using cached scipy-1.10.1.tar.gz (42.4 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Preparing metadata (pyproject.toml) did not run successfully.
  │ exit code: 1

╰─> [14 lines of output]
      + meson setup --prefix=C:\Users\XYZ\AppData\Local\Programs\Python\Python38-32 C:\Users\XYZ\AppData\Local\Temp\pip-

install-kcwepnco\scipy_545e8a24382142de9b0a2e3bbeb71b01 C:\Users\XYZ\AppData\Local\Temp\pip-install-kcwepnco

\scipy_545e8a24382142d
e9b0a2e3bbeb71b01\.mesonpy-k7npgzdq\build --native-file=C:\Users\XYZ\AppData\Local\Temp\pip-install-kcwepnco

\scipy_545e8a24382142de9b0a2e3bbeb71b01\.mesonpy-native-file.ini -Ddebug=false -Doptimization=2
      The Meson build system
      Version: 1.4.1
      Source dir: C:\Users\XYZ\AppData\Local\Temp\pip-install-kcwepnco\scipy_545e8a24382142de9b0a2e3bbeb71b01
      Build dir: C:\Users\XYZ\AppData\Local\Temp\pip-install-kcwepnco\scipy_545e8a24382142de9b0a2e3bbeb71b01\.mesonpy-
k7npgzdq\build
      Build type: native build
      Project name: SciPy
      Project version: 1.10.1
      C compiler for the host machine: cl (msvc 12.00.8168 "Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 

12.00.8168 for 80x86")
      C linker for the host machine: link link 6.00.8168

      ..\..\meson.build:1:0: ERROR: None of values ['c++14'] are supported by the C++ compiler. Possible values are 

['none', 'none', 'c++11', 'vc++11']

A full log can be found at...
[end of output]
...

 note: This error originates from a subprocess, and is likely not a problem with pip.
error: metadata-generation-failed

× Encountered error while generating package metadata.
╰─> See above for output.

note: This is an issue with the package mentioned above, not pip.
hint: See above for details.

I have no idea what is going on.

My OS is Windows 8 and Python verson is 3.8 .

I upgraded pip and also did try:

py -m pip install --upgrade pip setuptools wheel

But still no luck after that.

I am relatively new to python, so a detailed or easy solution using pip will be greatly appreciated.


Solution

  • The direct issue that you are seeing is, that scipy has a C-backend which pip is trying to compile, but finds that your compiler does not support options needed to do so:

     ERROR: None of values ['c++14'] are supported by the C++ compiler
    

    Usually, for this kind of library (and especially on windows), it can get quite complex to compile them yourself, which is why there are often pre-compiled versions available. If you look on https://pypi.org/project/scipy/1.10.1/#files you can see

    1. The "source distribution", which is the .tar.gz file
    2. "Binary distributions" - the .whl files which each have a tag for OS/python version, for example scipy-1.10.1-cp39-cp39-win_amd64.whl means scipy, version 1.10.1, CPython 3.9, windows x64

    You have a 32 bit variant of python, but if you check the linked list of available files for scipy 1.10.1, then there are no .whl files for windows that are not x64. This will not only make trouble with scipy, but also other packages, as supporting 32 bit python versions is not standard anymore.

    My reocmmendation is therefor to uninstall your current python version and install a 64 bit version instead. If possible, also consider using a more recent version of python.