python - 在 Windows 64 位上安装 cx_Oracle 时命令 'gcc' 失败,退出状态为 1

标签 python windows gcc x86-64 cx-oracle

我正在尝试在我的 Windows 7 - 64 位版本上安装 cx_Oracle。我之前有一个问题here关于在 Windows 上安装 cx_Oracle 我自己解决了这个问题;但它是 Windows 7 的 32 位版本;在这里我遇到了一个安装它的新问题。

我应该提到我部署了 64 位版本的 MinGW 以及 Microsoft Visual Studio 2008。对于这两个,我都得到了 command 'gcc' failed with exit status 1。我在 Microsoft Visual Studio 2008 控制台中尝试了 easy_install cx_Oracle 并得到了这个输出(这是我从 Windows 默认命令行运行命令时得到的结果):

Setting environment for using Microsoft Visual Studio 2008 x86 tools.

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>easy_install cx_Oracle
Searching for cx-Oracle
Reading http://pypi.python.org/simple/cx_Oracle/
Reading http://cx-oracle.sourceforge.net
Reading http://starship.python.net/crew/atuining
Best match: cx-Oracle 5.1.2
Downloading http://prdownloads.sourceforge.net/cx-oracle/cx_Oracle-5.1.2.tar.gz?
download
Processing cx_Oracle-5.1.2.tar.gz
Writing c:\users\user\appdata\local\temp\easy_install-txvil3\cx_Oracle-5.1.2\set
up.cfg
Running cx_Oracle-5.1.2\setup.py -q bdist_egg --dist-dir c:\users\user\appdata\l
ocal\temp\easy_install-txvil3\cx_Oracle-5.1.2\egg-dist-tmp-pjitbi
In file included from C:\oracle\instantclient_11_2\sdk\include/oci.h:541:0,
                 from cx_Oracle.c:10:
C:\oracle\instantclient_11_2\sdk\include/oratypes.h:236:25: error: expected '=',
 ',', ';', 'asm' or '__attribute__' before 'ubig_ora'
C:\oracle\instantclient_11_2\sdk\include/oratypes.h:237:25: error: expected '=',
 ',', ';', 'asm' or '__attribute__' before 'sbig_ora'
In file included from C:\oracle\instantclient_11_2\sdk\include/oci.h:3045:0,
                 from cx_Oracle.c:10:
C:\oracle\instantclient_11_2\sdk\include/ociap.h:7459:40: error: unknown type na
me 'ubig_ora'
C:\oracle\instantclient_11_2\sdk\include/ociap.h:7471:36: error: unknown type na
me 'ubig_ora'
C:\oracle\instantclient_11_2\sdk\include/ociap.h:8278:23: error: unknown type na
me 'sbig_ora'
C:\oracle\instantclient_11_2\sdk\include/ociap.h:8278:46: error: unknown type na
me 'sbig_ora'
In file included from Connection.c:776:0,
                 from SessionPool.c:139,
                 from cx_Oracle.c:198:
Callback.c: In function 'Callback_BindByNameArgs':
Callback.c:73:15: warning: variable 'errorHandle' set but not used [-Wunused-but
-set-variable]
Callback.c:72:15: warning: variable 'bindHandlePtr' set but not used [-Wunused-b
ut-set-variable]
Callback.c: In function 'Callback_DefineByPosArgs':
Callback.c:120:15: warning: variable 'errorHandle' set but not used [-Wunused-bu
t-set-variable]
Callback.c:118:17: warning: variable 'defineHandle' set but not used [-Wunused-b
ut-set-variable]
Callback.c: In function 'Callback_ExecuteArgs':
Callback.c:158:15: warning: variable 'errorHandle' set but not used [-Wunused-bu
t-set-variable]
Callback.c:157:16: warning: variable 'serviceContextHandle' set but not used [-W
unused-but-set-variable]
Callback.c: In function 'Callback_FetchArgs':
Callback.c:181:15: warning: variable 'errorHandle' set but not used [-Wunused-bu
t-set-variable]
Callback.c: In function 'Callback_PrepareArgs':
Callback.c:206:15: warning: variable 'errorHandle' set but not used [-Wunused-bu
t-set-variable]
error: Setup script exited with error: command 'gcc' failed with exit status 1

我还尝试使用 python setup.py build --compiler=mingw32 install 从源代码安装它,但我遇到了同样的错误。

我也试过 easy_install http://prdownloads.sourceforge.net/cx-oracle/cx_Oracle-5.1.2-11g.win-amd64-py2.7.msi?download;该 URL 是 cx_Oracle Windows amd64 安装程序(Oracle 11g,Python 2.7)的 sourceForge 链接。我明白了:

C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC>easy_install http://prdown
loads.sourceforge.net/cx-oracle/cx_Oracle-5.1.2-11g.win-amd64-py2.7.msi?download

Downloading http://prdownloads.sourceforge.net/cx-oracle/cx_Oracle-5.1.2-11g.win
-amd64-py2.7.msi?download
Processing cx_Oracle-5.1.2-11g.win-amd64-py2.7.msi
error: Not a recognized archive type: c:\users\user\appdata\local\temp\easy_inst
all-ys4fjr\cx_Oracle-5.1.2-11g.win-amd64-py2.7.msi

为了完整起见,我应该说我使用的是 oracle 即时客户端 11。我已经设置了 PATHORACLE_HOME 环境变量。我机器上的其他数据库应用程序(如 Navicat)与此客户端配合良好。知道这个安装有什么问题吗?

最佳答案

实际上您正在尝试在您引用的 url 中下载 cx_Oracle 的二进制文件

http://prdownloads.sourceforge.net/cx-oracle/cx_Oracle-5.1.2-11g.win-amd64-py2.7.msi

指向的文件是一个 *.msi 文件,代表 Microsoft Installer 并包含预编译的内容。因此,不要使用 pip/easy_install 来执行 cx_Oracle 的设置,只需双击 msi 文件即可;这将安装所有需要的文件(.pyd 和 .so 文件)。

关于python - 在 Windows 64 位上安装 cx_Oracle 时命令 'gcc' 失败,退出状态为 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23467014/

相关文章:

python - 过滤 pandas 数据帧列表以仅包含以 a 结尾的行索引

python - 训练新的 AutoTokenizer 拥抱脸部

c - Windows命令: cannot get the input character properly

c++ - 结合 blits 和 gdi 绘图(不工作,闪烁)

python - 并行磁盘 I/O

python - 如何创建带有按钮的网页,这些按钮在为网页提供服务的系统上调用各种 Python 脚本?

c++ - GCC 中的模板看不到在它之后声明的函数,而是在实例化之前

c++ - 编译器是否将给定常量参数的简单函数简化为唯一指令?

windows - C : Correct Way to Statically/Dynamically Link with MinGW-w64

python - 如何在 Windows 命令提示符下运行 python 文件?