Python 错误:无法为 cx_Oracle 构建轮子,这是安装基于 pyproject.toml 的项目所必需的

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

我正在尝试安装 cx_Oracle,但收到此错误, 我安装了最新的 setuptools 和 pip。 有没有人遇到过类似的问题,是怎么解决的?

我有 Visual Studio:请参阅图片

Microsoft Visual C++ Redistributable Versions listed

Processing c:\....resources\cx_oracle-8.1.0.tar.gz
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: cx_Oracle
  Building wheel for cx_Oracle (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for cx_Oracle (pyproject.toml) did not run successfully.
  ¦ exit code: 1
  ?-> [7 lines of output]
      C:\....\2\pip-build-env-806_5jc6\overlay\Lib\site-packages\setuptools\config\expand.py:144: UserWarning: File 'C:\\....\\2\\pip-install-r8jb3ohi\\cx-oracle_111cfa7e3d91425bb65e9a6baa89c82f\\README.md' cannot be found
        warnings.warn(f"File {path!r} cannot be found")
      running bdist_wheel
      running build
      running build_ext
      building 'cx_Oracle' extension
      error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for cx_Oracle
Failed to build cx_Oracle
ERROR: Could not build wheels for cx_Oracle, which is required to install pyproject.toml-based projects
python cx-oracle
3个回答
0
投票

可能是因为python的版本问题,我用3.10.9的时候可以,但是3.11.0不行


0
投票

您显示的图像具有 可再发行组件,而不是 Visual Studio 本身!如果您想自己构建,则需要按照提供的链接安装 Microsoft 构建工具。

但是,如果您使用 pip,您应该能够下载并安装预构建的二进制文件——这要容易得多!使用的命令是:

python -m pip install cx_Oracle

编辑:cx_Oracle 已被 python-oracledb 取代。通过此命令安装:

python -m pip install oracledb

0
投票

或者,您可以为您的操作系统安装 Anaconda,然后运行以下命令来安装 cx_oracle。 Anaconda 负责整个构建过程(轮子问题)。

conda安装-c anaconda cx_oracle

真的有效!!!

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