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

Tom*_*ski 6 python cx-oracle

我正在尝试安装 cx_Oracle,但收到此错误,\n我安装了最新的 setuptools 和 pip。\n有人遇到过类似的问题吗?他们是如何解决的?

\n

我有 Visual Studio:请参见图片

\n

列出的 Microsoft Visual C++ 可再发行版本

\n
Processing c:\\....resources\\cx_oracle-8.1.0.tar.gz\n  Installing build dependencies ... done\n  Getting requirements to build wheel ... done\n  Preparing metadata (pyproject.toml) ... done\nBuilding wheels for collected packages: cx_Oracle\n  Building wheel for cx_Oracle (pyproject.toml) ... error\n  error: subprocess-exited-with-error\n\n  \xc3\x97 Building wheel for cx_Oracle (pyproject.toml) did not run successfully.\n  \xc2\xa6 exit code: 1\n  ?-> [7 lines of output]\n      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\n        warnings.warn(f"File {path!r} cannot be found")\n      running bdist_wheel\n      running build\n      running build_ext\n      building \'cx_Oracle\' extension\n      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/\n      [end of output]\n\n  note: This error originates from a subprocess, and is likely not a problem with pip.\n  ERROR: Failed building wheel for cx_Oracle\nFailed to build cx_Oracle\nERROR: Could not build wheels for cx_Oracle, which is required to install pyproject.toml-based projects\n
Run Code Online (Sandbox Code Playgroud)\n

Ant*_*nga 5

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

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

python -m pip install cx_Oracle
Run Code Online (Sandbox Code Playgroud)

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

python -m pip install oracledb
Run Code Online (Sandbox Code Playgroud)