You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

安装Python的cx_Oracle库时出现编译错误,求有效解决方案

解决cx_Oracle安装失败的问题

安装报错信息

# python -m pip install cx_Oracle
Collecting cx_Oracle
  Using cached cx_Oracle-8.3.0.tar.gz (363 kB)
  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
  ╰─> [8 lines of output]
      <string>:6: DeprecationWarning: pkg_resources is deprecated as an API. See https://setuptools.pypa.io/en/latest/pkg_resources.html
      C:\Users\Administrator\AppData\Local\Temp\pip-build-env-jb_g39xc\overlay\Lib\site-packages\setuptools\config\expand.py:134: SetuptoolsWarning: File 'C:\\Users\\Administrator\\AppData\\Local\\Temp\\pip-install-u3v1mhmi\\cx-oracle_552b461268374c8e84e109da373d4d00\\README.md' cannot be found
        return '\n'.join(
      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

错误核心原因

报错中的关键提示error: Microsoft Visual C++ 14.0 or greater is required表明:cx_Oracle需要编译C语言扩展模块,本地缺少对应的VC++编译工具链,导致无法构建wheel包。

有效解决方案

方案1:安装预编译二进制包(推荐,无需本地编译)

直接通过pip获取预编译好的wheel包,跳过编译步骤:

pip install cx-oracle --only-binary :all:

方案2:安装VC++构建工具(支持本地编译)

  1. 下载并安装Microsoft C++ Build Tools,安装时必须勾选「C++构建工具」组件,同时选择与当前系统版本匹配的Windows SDK。
  2. 安装完成后重启命令提示符,重新执行安装命令:
python -m pip install cx_Oracle

内容的提问来源于stack exchange,提问作者Ashuu

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.28 23:47:49