Cannot install Scipy using pip on Windows

I have a Windows computer and I tried installing SciPy in the Command Prompt using pip. pip install ... worked for other packages that I have installed; however, for scipy, it gave me an error. Any help would be great Below is the error message:

C:\Users\mharvest>pip install scipy
Collecting scipy
  Using cached scipy-1.9.1.tar.gz (42.0 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... error
  error: subprocess-exited-with-error

  × Getting requirements to build wheel did not run successfully.
  │ exit code: 1
  ╰─> [55 lines of output]
      The Meson build system
      Version: 0.62.2
      Source dir: C:\Users\mharvest\AppData\Local\Temp\pip-install-jvemq8sw\scipy_46a2c46b25884e73b044795d4031c57c
      Build dir: C:\Users\mharvest\AppData\Local\Temp\pip-install-jvemq8sw\scipy_46a2c46b25884e73b044795d4031c57c\.mesonpy-ouof6i1j\build
      Build type: native build
      Project name: SciPy
      Project version: 1.9.1
      WARNING: Failed to activate VS environment: Could not parse vswhere.exe output

      ..\..\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\mharvest\AppData\Local\Temp\pip-install-jvemq8sw\scipy_46a2c46b25884e73b044795d4031c57c\.mesonpy-ouof6i1j\build\meson-logs\meson-log.txt
      + meson setup --native-file=C:\Users\mharvest\AppData\Local\Temp\pip-install-jvemq8sw\scipy_46a2c46b25884e73b044795d4031c57c\.mesonpy-native-file.ini -Ddebug=false -Doptimization=2 --prefix=C:\Users\mharvest\AppData\Local\Programs\Python\Python311-32 C:\Users\mharvest\AppData\Local\Temp\pip-install-jvemq8sw\scipy_46a2c46b25884e73b044795d4031c57c C:\Users\mharvest\AppData\Local\Temp\pip-install-jvemq8sw\scipy_46a2c46b25884e73b044795d4031c57c\.mesonpy-ouof6i1j\build
      Traceback (most recent call last):
        File "C:\Users\mharvest\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 363, in <module>
          main()
        File "C:\Users\mharvest\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 345, in main
          json_out['return_val'] = hook(**hook_input['kwargs'])
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\mharvest\AppData\Local\Programs\Python\Python311-32\Lib\site-packages\pip\_vendor\pep517\in_process\_in_process.py", line 130, in get_requires_for_build_wheel
          return hook(config_settings)
                 ^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\mharvest\AppData\Local\Temp\pip-build-env-bjmh2uho\overlay\Lib\site-packages\mesonpy\__init__.py", line 923, in get_requires_for_build_wheel
          with _project(config_settings) as project:
        File "C:\Users\mharvest\AppData\Local\Programs\Python\Python311-32\Lib\contextlib.py", line 137, in __enter__
          return next(self.gen)
                 ^^^^^^^^^^^^^^
        File "C:\Users\mharvest\AppData\Local\Temp\pip-build-env-bjmh2uho\overlay\Lib\site-packages\mesonpy\__init__.py", line 902, in _project
          with Project.with_temp_working_dir(
        File "C:\Users\mharvest\AppData\Local\Programs\Python\Python311-32\Lib\contextlib.py", line 137, in __enter__
          return next(self.gen)
                 ^^^^^^^^^^^^^^
        File "C:\Users\mharvest\AppData\Local\Temp\pip-build-env-bjmh2uho\overlay\Lib\site-packages\mesonpy\__init__.py", line 547, in with_temp_working_dir
          yield cls(source_dir, tmpdir, build_dir)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\mharvest\AppData\Local\Temp\pip-build-env-bjmh2uho\overlay\Lib\site-packages\mesonpy\__init__.py", line 463, in __init__
          self._configure(reconfigure=bool(build_dir) and not native_file_mismatch)
        File "C:\Users\mharvest\AppData\Local\Temp\pip-build-env-bjmh2uho\overlay\Lib\site-packages\mesonpy\__init__.py", line 494, in _configure
          self._meson(
        File "C:\Users\mharvest\AppData\Local\Temp\pip-build-env-bjmh2uho\overlay\Lib\site-packages\mesonpy\__init__.py", line 477, in _meson
          return self._proc('meson', *args)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "C:\Users\mharvest\AppData\Local\Temp\pip-build-env-bjmh2uho\overlay\Lib\site-packages\mesonpy\__init__.py", line 472, in _proc
          subprocess.check_call(list(args))
        File "C:\Users\mharvest\AppData\Local\Programs\Python\Python311-32\Lib\subprocess.py", line 413, in check_call
          raise CalledProcessError(retcode, cmd)
      subprocess.CalledProcessError: Command '['meson', 'setup', '--native-file=C:\\Users\\mharvest\\AppData\\Local\\Temp\\pip-install-jvemq8sw\\scipy_46a2c46b25884e73b044795d4031c57c\\.mesonpy-native-file.ini', '-Ddebug=false', '-Doptimization=2', '--prefix=C:\\Users\\mharvest\\AppData\\Local\\Programs\\Python\\Python311-32', 'C:\\Users\\mharvest\\AppData\\Local\\Temp\\pip-install-jvemq8sw\\scipy_46a2c46b25884e73b044795d4031c57c', 'C:\\Users\\mharvest\\AppData\\Local\\Temp\\pip-install-jvemq8sw\\scipy_46a2c46b25884e73b044795d4031c57c\\.mesonpy-ouof6i1j\\build']' returned non-zero exit status 1.
      [end of output]

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

× Getting requirements to build wheel did not run successfully.
│ exit code: 1
╰─> See above for output.

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

  • try py -m pip install scipy

    – 

  • Thanks, but no luck.

    – 

  • Try this one py -m ensurepip –default-pip and then py -m pip install –upgrade pip setuptools wheel and finally type py -m pip install scipy. If py does not work try python or python3.

    – 

Judging from the traceback you appear to be using 32-bit Python3.11

There are no 32-bit wheels available for scipy-1.9.2. Whilst there are 32-bit wheels available for 1.9.1, but don’t target Python 3.11.

Installing a 64 bit Python interpreter should fix this issue. Although Python3.11 hasn’t been released yet you can find the 64-bit installer at https://www.python.org/downloads/release/python-3110rc2/

install scipy 1.8.1 version
it’s solve my problem install it and if you get “ould not build wheels for scipy which use PEP 517 and cannot be installed directly”
error.
upgrade pip

The important part of the error message is ERROR: Unknown compiler(s), informing us that a C compiler was not found:

..\..\meson.build:1:0: ERROR: Unknown compiler(s): [['icl'], ['cl'], ['cc'], ['gcc'], ['clang'], ['clang-cl'], ['pgcc']]

After you fix this, you’re also going to need a C++ compiler, a Fortran compiler, the Python header files, cmake, and a handful of other low-level tools.

TL;DR: Compiling SciPy on Windows is hard. You might follow Andrew Nelson’s suggestion to install a 64-bit version of Python and use pip to fetch pre-built wheels. Or you might setup Anaconda/Miniconda for Windows and install SciPy with:

conda install scipy

Further Reading:

Leave a Comment