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

1 投票
1 回答
2030 浏览
提问于 2025-04-18 05:23

我正在尝试在我的Windows 7 64位系统上安装cx_Oracle。之前我在这里问过关于在Windows上安装cx_Oracle的问题,并且自己解决了那个问题;但那时我用的是32位的Windows 7,这次在安装时遇到了新问题。

我得提一下,我安装了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来安装;这个链接是sourceForge上cx_Oracle Windows amd64安装程序的地址(Oracle 11g,Python 2.7)。结果是这样的:

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 Instant Client 11。我已经设置了PATHORACLE_HOME这两个环境变量。我的机器上其他数据库应用,比如Navicat,和这个客户端配合得很好。请问这个安装到底出了什么问题呢?

1 个回答

2

其实你是在尝试下载cx_Oracle的二进制文件,链接指向的就是这个。

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

这个文件是一个*.msi格式的文件,代表的是微软安装程序,里面包含了已经编译好的内容。所以,你不需要用pip或easy_install来安装cx_Oracle,只需双击这个msi文件;这样就会安装所有需要的文件(包括.pyd和.so文件)。

撰写回答