32位Python虚拟环境安装scikit-image报错求助
解决32位Python虚拟环境中scikit-image安装的架构不匹配问题
问题描述
64位Windows系统中同时安装了32位和64位Python 3.9.13,在VSCode创建的32位虚拟环境中执行python -m pip install -U scikit-image时,Meson构建系统报错:Need python for x86_64, but found x86,最终提示Python dependency not found。已确认当前环境为32位且路径配置正常,64位Python环境可正常安装该库,依赖列表也已核对无误。
完整报错日志:
(.venv) C:\Users\osimsek\Desktop\Python\vscode_venv_x86>python -m pip install -U scikit-image Collecting scikit-image Using cached scikit_image-0.22.0.tar.gz (22.7 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 ╰─> [28 lines of output] + meson setup C:\Users\osimsek\AppData\Local\Temp\pip-install-9pouxues\scikit-image_959a707540ba4f3d9c6bef5cbffc6d12 C:\Users\osimsek\AppData\Local\Temp\pip-install-9pouxues\scikit-image_959a707540ba4f3d9c6bef5cbffc6d12\.mesonpy-agpxo0eg -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md --native-file=C:\Users\osimsek\AppData\Local\Temp\pip-install-9pouxues\scikit-image_959a707540ba4f3d9c6bef5cbffc6d12\.mesonpy-agpxo0eg\meson-python-native-file.ini The Meson build system Version: 1.2.2 Source dir: C:\Users\osimsek\AppData\Local\Temp\pip-install-9pouxues\scikit-image_959a707540ba4f3d9c6bef5cbffc6d12 Build dir: C:\Users\osimsek\AppData\Local\Temp\pip-install-9pouxues\scikit-image_959a707540ba4f3d9c6bef5cbffc6d12\.mesonpy-agpxo0eg Build type: native build Project name: scikit-image Project version: 0.22.0 Activating VS 17.7.1 C compiler for the host machine: cl (msvc 19.37.32822 "x64 için Microsoft (R) C/C++ İyileştirmeli Derleyici Sürüm 19.37.32822") C linker for the host machine: link link 14.37.32822.0 C++ compiler for the host machine: cl (msvc 19.37.32822 "x64 için Microsoft (R) C/C++ İyileştirmeli Derleyici Sürüm 19.37.32822") C++ linker for the host machine: link link 14.37.32822.0 Host machine cpu family: x86_64 Host machine cpu: x86_64 Compiler for C supports arguments -Wno-unused-function: NO Library m found: NO Checking if "-Wl,--version-script" : links: NO Program cython found: YES (C:\Users\osimsek\AppData\Local\Temp\pip-build-env-egn3taya\overlay\Scripts\cython.EXE) Program pythran found: YES (C:\Users\osimsek\AppData\Local\Temp\pip-build-env-egn3taya\overlay\Scripts\pythran.EXE) Program cp found: YES (C:\cygwin\bin\cp.EXE) Program python found: YES (C:\Users\osimsek\Desktop\Python\vscode_venv_x86\.venv\Scripts\python.exe) Need python for x86_64, but found x86 Run-time dependency python found: NO (tried sysconfig) ..\meson.build:69:14: ERROR: Python dependency not found A full log can be found at C:\Users\osimsek\AppData\Local\Temp\pip-install-9pouxues\scikit-image_959a707540ba4f3d9c6bef5cbffc6d12\.mesonpy-agpxo0eg\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.
解决方案
1. 切换到32位MSVC编译环境
报错日志显示当前使用的是x64版本的MSVC编译器,32位Python环境需要对应x86的编译工具链:
- 打开Visual Studio开发者命令提示符(x86)(根据你的VS版本选择对应工具,比如VS 2022对应"Developer Command Prompt for VS 2022 (x86)")
- 在该命令行中激活32位虚拟环境:
C:\Users\osimsek\Desktop\Python\vscode_venv_x86\.venv\Scripts\activate.bat - 再次执行安装命令:
python -m pip install -U scikit-image
如果使用VSCode终端,可先运行VS的32位环境配置脚本(路径根据你的VS安装位置调整):
"C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvars32.bat"
激活虚拟环境后再执行pip安装。
2. 强制指定Meson构建架构
在pip安装时传递Meson参数,强制指定x86架构:
python -m pip install -U scikit-image --config-settings=setup-args=-Dhost_cpu=x86
或者先设置环境变量再安装:
SET MESON_ARGS=-Dhost_cpu=x86 python -m pip install -U scikit-image
3. 尝试安装预编译wheel包
升级pip和wheel后,优先使用预编译包避免源码编译:
python -m pip install -U pip wheel python -m pip install -U scikit-image --only-binary :all:
注:需确认scikit-image提供了Python 3.9的32位预编译wheel,若没有则需回到前两种方案。
4. 再次确认虚拟环境架构
执行以下命令验证当前环境是否为32位:
python -c "import platform; print(platform.architecture())"
输出应为('32bit', 'WindowsPE'),确保虚拟环境确实基于32位Python创建。
内容的提问来源于stack exchange,提问作者oguzhantr
相关产品推荐
相关产品推荐

