尝试在华硕 ZenBook 笔记本电脑上安装 pyodbc 时出错:无法为 pyodbc 构建轮子

问题描述 投票:0回答:1

我正在尝试安装 pyodbc。我有 python 3.12 和 VS 2022。我已经下载了 Microsoft C++ Build Tools for VS。当我运行“pip install pyodbc”时,出现以下错误:

Defaulting to user installation because normal site-packages is not writeable
Collecting pyodbc
  Using cached pyodbc-4.0.35.tar.gz (273 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: pyodbc
  Building wheel for pyodbc (pyproject.toml) ... error
  error: subprocess-exited-with-error

      error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2022\\BuildTools\\VC\\Tools\\MSVC\\14.35.32215\\bin\\HostX86\\x64\\cl.exe' failed with exit code 2
      [end of output]
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pyodbc
Failed to build pyodbc
ERROR: Could not build wheels for pyodbc, which is required to install pyproject.toml-based projects

我有 python 3.12 和 VS 2022。我已经下载了 Microsoft C++ Build Tools for VS。

python command-prompt pyodbc
1个回答
0
投票

根据评论,解决方案是从 Python 3.12 降级到 Python 3.11。

在我撰写本文时,Python 3.12 尚未普遍可用,仅作为预发布版本 (3.12.0a6)。因此,pyodbc 维护者很可能没有为 Python 3.12 的 pyodbc 构建二进制轮子。如果没有二进制轮,pyodbc 的本机部分必须从源代码构建,这将需要 C/C++ 编译器和构建工具。然而,在这种情况下,构建包时似乎遇到了编译器错误,因此包安装失败。

具体的编译错误是什么,错误是在pyodbc还是Python 3.12,我不能说。

© www.soinside.com 2019 - 2024. All rights reserved.