我正在尝试为Python 2.6安装cx_Oracle,但它失败了。我对C或MS Vis知之甚少。 Studio的编译器甚至可以自己修复它。
这是命令行输出的内容:
C:\pydev\cx_Oracle-5.0.1>C:\python26\python setup.py install
running install
running build
running build_ext
building 'cx_Oracle' extension
C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Oracle\instantclient\sdk\include -IC:\p
ython26\include -IC:\python26\PC /Tccx_Oracle.c /Fobuild\temp.win32-2.6-11g\Release\cx_Oracle.obj -DBUILD_VERSION=5.0.1
cx_Oracle.c
c:\pydev\cx_oracle-5.0.1\StringVar.c(392) : warning C4018: '>' : signed/unsigned mismatch
c:\pydev\cx_oracle-5.0.1\StringVar.c(417) : warning C4018: '>' : signed/unsigned mismatch
c:\pydev\cx_oracle-5.0.1\ObjectVar.c(117) : warning C4018: '<' : signed/unsigned mismatch
c:\pydev\cx_oracle-5.0.1\ObjectVar.c(134) : warning C4018: '<' : signed/unsigned mismatch
c:\pydev\cx_oracle-5.0.1\Variable.c(331) : error C2036: 'void *' : unknown size
c:\pydev\cx_oracle-5.0.1\Variable.c(878) : warning C4244: '=' : conversion from 'sb2' to 'sb1', possible loss of data
c:\pydev\cx_oracle-5.0.1\Variable.c(914) : warning C4018: '<' : signed/unsigned mismatch
error: command '"C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' failed with exit status 2
有没有人知道如何解决这个问题? (我也可能有一个cl.exe文件的问题,我想我记得在其他地方看到这个问题,但我有四台Windows机器可能有问题。)。
----------------------------- EDIT -------------- ---------------
我不使用预编译安装程序的原因是因为当我尝试运行模块时,我得到以下内容:
Python 2.6.3 (r263rc1:75186, Oct 2 2009, 20:40:30) [MSC v.1500 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import cx_Oracle Traceback (most recent call last): File "", line 1, in ImportError: DLL load failed: The specified module could not be found.
我认为这意味着它没有正确安装。如果有人能告诉我这里做错了什么,这也是一个完全可以接受的答案。
----------------------------- EDIT2 -------------- ---------------
我从Oracle's Basic Client版本11.1.0.7检索了所有文件。我没有尝试安装更实质的客户端。我现在正在下载一个。
%ORACLE_HOME%=C:\Oracle\instantclient\ #The directory where the above files have been extracted.
答案 0 :(得分:18)
为什么不使用像Windows Installer (Oracle 10g, Python 2.6)这样的二进制包?
有关其他二进制包的信息,请参阅http://cx-oracle.sourceforge.net/
附录(根据要求):您必须确保使用以下的cx_Oracle:
oraocci11.dll
,Oracle 10g的oraocci10.dll
或Oracle 9i的oraclient9.dll
你PATH环境变量答案 1 :(得分:8)
您还需要在您的计算机上安装某种类型的Oracle客户端,因为cx_Oracle只是Python和Oracle客户端之间的桥梁。有效的Oracle客户端包括完整的Oracle安装(如Standard或XE)或Instant Client
来自README:
请注意Oracle客户端(或 服务器)安装是必需的 为了使用cx_Oracle。如果你不 需要随附的工具 完整的客户端安装,它是 建议安装Instant 客户端更容易安装。
之前我没有在Windows上安装,但您可能必须设置ORACLE_HOME环境变量,以便cx_Oracle知道要查找的位置。
答案 2 :(得分:3)
如果你使用Anaconda Python x64,那就是easier:
conda install -c https://conda.anaconda.org/anaconda cx_oracle
(它将安装正确的Oracle客户端)
如果您收到以下错误:
[Anaconda2] C:\Users\User>conda install -c https://conda.anaconda.org/anaconda c
x_oracle
Using Anaconda Cloud api site https://api.anaconda.org
Fetching package metadata: ......
Solving package specifications: .................
Package plan for installation in environment C:\Anaconda2:
The following NEW packages will be INSTALLED:
cx_oracle: 5.1.2-py27_0
oracle-instantclient: 11.2.0.4.0-0
The following packages will be UPDATED:
conda: 3.19.1-py27_0 --> 4.0.5-py27_0
pip: 8.0.2-py27_0 --> 8.1.1-py27_0
pyyaml: 3.11-py27_2 --> 3.11-py27_3
setuptools: 19.6.2-py27_0 --> 20.3-py27_0
wheel: 0.26.0-py27_1 --> 0.29.0-py27_0
Proceed ([y]/n)? y
Unlinking packages ...
An unexpected error has occurred, please consider sending the | 0%
following traceback to the conda GitHub issue tracker at:
https://github.com/conda/conda/issues
Include the output of the command 'conda info' in your report.
Traceback (most recent call last):
File "C:\Anaconda2\Scripts\conda-script.py", line 4, in <module>
sys.exit(main())
File "C:\Anaconda2\lib\site-packages\conda\cli\main.py", line 173, in main
args_func(args, p)
File "C:\Anaconda2\lib\site-packages\conda\cli\main.py", line 180, in args_fun
c
args.func(args, p)
File "C:\Anaconda2\lib\site-packages\conda\cli\main_install.py", line 45, in e
xecute
install.install(args, parser, 'install')
File "C:\Anaconda2\lib\site-packages\conda\cli\install.py", line 423, in insta
ll
plan.execute_actions(actions, index, verbose=not args.quiet)
File "C:\Anaconda2\lib\site-packages\conda\plan.py", line 538, in execute_acti
ons
inst.execute_instructions(plan, index, verbose)
File "C:\Anaconda2\lib\site-packages\conda\instructions.py", line 148, in exec
ute_instructions
cmd(state, arg)
File "C:\Anaconda2\lib\site-packages\conda\instructions.py", line 95, in UNLIN
K_CMD
install.unlink(state['prefix'], arg)
File "C:\Anaconda2\lib\site-packages\conda\install.py", line 714, in unlink
os.unlink(meta_path)
WindowsError: [Error 5] Access is denied: 'C:\\Anaconda2\\conda-meta\\conda-3.19
.1-py27_0.json'
[Anaconda2] C:\Users\User>
尝试以管理员身份运行Anaconda提示: