安装pyodbc时出现错误,无法为pyodbc构建轮子。

huangapple go评论67阅读模式
英文:

Error trying to install pyodbc on ASUS ZenBook Laptop: Couldn not build wheels for pyodbc

问题

我正在尝试安装pyodbc。我有Python 3.12和VS 2022。我已经下载了用于VS的Microsoft C++构建工具。当我运行"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。我已经下载了用于VS的Microsoft C++构建工具。

英文:

I am trying to install pyodbc. I have python 3.12 and VS 2022. I have downloaded Microsoft C ++ Build Tools for VS. When I run "pip install pyodbc" I get the following error:

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\22\\BuildTools\\VC\\Tools\\MSVC\.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

I have python 3.12 and VS 2022. I have downloaded Microsoft C ++ Build Tools for VS.

答案1

得分: 1

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

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

确切的编译器错误是什么,以及错误是否出现在pyodbc或Python 3.12中,我无法确定。

英文:

From the comments, the solution was to downgrade from Python 3.12 to Python 3.11.

As I write this, Python 3.12 has not been made generally available, only as a pre-release (3.12.0a6). It is therefore likely that the pyodbc maintainers have not built binary wheels for pyodbc for Python 3.12. With no binary wheel, the native part of pyodbc would have to be built from source, and that would require a C/C++ compiler and build tools. In this case, however, it seems a compiler error has been encountered building the package, so the package installation has failed.

What the precise compiler error is, and whether the error is in pyodbc or Python 3.12, I cannot say.

huangapple
  • 本文由 发表于 2023年4月4日 05:10:44
  • 转载请务必保留本文链接:https://go.coder-hub.com/75923799.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定