我正在尝试使用以下方式安装特定版本的 scipy:
pip install "scipy==1.10.1"
但是我遇到了一个无法解释的错误:
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.
背景:
我有一台机器,安装有 Python 3.8.3、numpy 1.24.4、scipy 1.10.1 和 OpenCV 4.2.0。我想让我的另一台机器与它完全匹配。
这些都是 Windows 10 机器。
到目前为止,Python 3.8.3、numpy 1.24.4 和 OpenCV 4.2.0 都安装良好。但是当我尝试安装 scipy(任何版本)时,我收到相同的错误消息。
我似乎找不到带有正确版本的 scipy 和匹配的 python 版本的轮子。
问题:
似乎您需要安装了 C/C++ 堆栈的 Visual Studio,因为该安装脚本正在尝试调用 vswhere 来确定 C 编译器在哪里。
您可能想使用 SciPy 的替代发行版,最好是已经预编译的发行版。
推荐的获取方式是通过 Anaconda,如下所述: https://scipy.org/install/ 如果您不想安装 Anaconda,您可能想像在 Windows 上一样尝试 WinPython。