解决Python安装cx_Oracle失败的常见错误
C:\Users\hspcadmin>pip3 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\hspcadmin\AppData\Local\Temp\pip-build-env-wz1x8fcs\overlay\Lib\site-packages\setuptools\config\expand.py:133: SetuptoolsWarning: File 'C:\\Users\\hspcadmin\\AppData\\Local\\Temp\\pip-install-b815qnb9\\cx-oracle_5fdb6c3699b94b47b0d0aae7c80aa61a\\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
经过各种搜索排查,发现 cx_Oracle 支持最高python是3.10 = = ,我下载的版本是python-3.12.3-amd64.exe。不支持。
https://pypi.org/project/cx-Oracle/#files
再见了 python 12 = =
保证卸载干净,然后重新安装python10低版本。新手这里需要注意,可能卸载后,安装python10,cmd命令窗口找不到python 或者pip命令。注意需要重新检查环境变量。保证是python10的路径和对应的pip。先看一下python10,执行cx_oracle的成功界面。(emmmm我就是反复卸载安装配置环境变量。。。折腾好几遍)
作者:逆天小北鼻