Search code examples
pythonpipscipywindows-10

pip install "scipy==1.10.1" - What does this error message even mean?


I am trying to install a specific version of scipy using:

pip install "scipy==1.10.1"

But I'm getting an error I can't interpret:

  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
  ╰─> [21 lines of output]
      + meson setup --prefix=c:\users\hugo\appdata\local\programs\python\python38-32 C:\Users\hugo\AppData\Local\Temp\pip-install-e_otiu7s\scipy_a4dec49d0df54c3884f33ca8aa92cddf C:\Users\hugo\AppData\Local\Temp\pip-install-e_otiu7s\scipy_a4dec49d0df54c3884f33ca8aa92cddf\.mesonpy-hi22c8nm\build --native-file=C:\Users\hugo\AppData\Local\Temp\pip-install-e_otiu7s\scipy_a4dec49d0df54c3884f33ca8aa92cddf\.mesonpy-native-file.ini -Ddebug=false -Doptimization=2
      The Meson build system
      Version: 1.3.1
      Source dir: C:\Users\hugo\AppData\Local\Temp\pip-install-e_otiu7s\scipy_a4dec49d0df54c3884f33ca8aa92cddf
      Build dir: C:\Users\hugo\AppData\Local\Temp\pip-install-e_otiu7s\scipy_a4dec49d0df54c3884f33ca8aa92cddf\.mesonpy-hi22c8nm\build
      Build type: native build
      Project name: SciPy
      Project version: 1.10.1
      WARNING: Failed to activate VS environment: Could not find C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe

      ..\..\meson.build:1:0: ERROR: Unknown compiler(s): [['icl'], ['cl'], ['cc'], ['gcc'], ['clang'], ['clang-cl'], ['pgcc']]
      The following exception(s) were encountered:
      Running `icl ""` gave "[WinError 2] The system cannot find the file specified"
      Running `cl /?` gave "[WinError 2] The system cannot find the file specified"
      Running `cc --version` gave "[WinError 2] The system cannot find the file specified"
      Running `gcc --version` gave "[WinError 2] The system cannot find the file specified"
      Running `clang --version` gave "[WinError 2] The system cannot find the file specified"
      Running `clang-cl /?` gave "[WinError 2] The system cannot find the file specified"
      Running `pgcc --version` gave "[WinError 2] The system cannot find the file specified"

      A full log can be found at C:\Users\hugo\AppData\Local\Temp\pip-install-e_otiu7s\scipy_a4dec49d0df54c3884f33ca8aa92cddf\.mesonpy-hi22c8nm\build\meson-logs\meson-log.txt
      [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.

Background:

I have one machine with Python 3.8.3, numpy 1.24.4, scipy 1.10.1 and OpenCV 4.2.0. I would like to make my other machine match it exactly.

These are both Windows 10 machines.

So far, Python 3.8.3, numpy 1.24.4 and OpenCV 4.2.0 are installed fine. But when I try to install scipy (of any version) I get the same error messages.

I can't seem to find a wheel with the right version of scipy and a matching python version.

Questions:

  • What is the meaning of these errors?
  • Do I need to install gcc, clang, vswhere.exe, etc.?
  • How can I install scipy?

Solution

  • It looks like you are using a 32-bit Python version, which does not have wheels available for SciPy. If you can use 64-bit Python that would solve this problem. Alternatively, you will need to install a Visual Studio compiler that can build SciPy.

    (You can tell it's 32-bit because of this part of meson's output: --prefix=c:\users\hugo\appdata\local\programs\python\python38-32)

    You can see what wheels are avaialable here: https://pypi.org/simple/scipy/

    You can see that scipy-1.10.1-cp38-cp38-win_amd64.whl is there, but there is not a 32-bit equivalent version.