Anaconda 3.5(64位Windows)安装cx_Oracle [英] Anaconda 3.5 (64bit Windows) Install cx_Oracle
问题描述
我已经为Windows 64位安装了Anaconda 3.5,并且需要使用软件包"cx_Oracle"连接到Oracle数据库.
I have installed Anaconda 3.5 for Windows 64bits, and I need to connect to the Oracle database using package "cx_Oracle".
我尝试了anaconda方式:
I tried with the anaconda way:
conda install -c https://conda.anaconda.org/anaconda cx_oracle
以下错误消息:
Hint: the following packages conflict with each other:
- cx_oracle
- python 3.5*
Use 'conda info cx_oracle' etc. to see the dependencies for each package.
Note that the following features are enabled:
- vc14
似乎cx_oracle与Python 3.5不兼容.
It seems that cx_oracle isn't compatible with Python 3.5.
此后,我还尝试直接使用二进制文件进行安装:
After this, I also tried to install directly with the binary:
python setup.py install
它会引发很多错误,例如:
It throws a bunch of errors like:
cx_Oracle.obj : error LNK2001: unresolved external symbol OCILobGetChunkSize
cx_Oracle.obj : error LNK2001: unresolved external symbol OCIStmtExecute
cx_Oracle.obj : error LNK2001: unresolved external symbol OCILobFileClose
有没有一种方法可以为Anaconda 3.5安装cx_oracle?
Is there a way to install cx_oracle for Anaconda 3.5 ??
推荐答案
有点不平凡.但是可行.请按照下列步骤操作:
It's kind of non-trivial. However doable. Follow these steps:
1)从
http://www.oracle.com/technetwork/topics/winx64soft -089540.html
例如选择客户,例如11.2.0.4
e.g. choose client e.g. 11.2.0.4
-> Instantclient-basic-windows.x64-11.2.0.4.0.zip
-> instantclient-basic-windows.x64-11.2.0.4.0.zip
-> Instantclient-sdk-windows.x64-12.1.0.2.0.zip
-> instantclient-sdk-windows.x64-12.1.0.2.0.zip
2)创建目录并解压缩客户端& sdk在其中:
例如c:\ ora \ 11gx64
e.g. c:\ora\11gx64
3)设置ORACLE_HOME和TNS_ADMIN
请参见 https://superuser.com/问题/949560/如何在Windows 10中设置系统环境变量
例如 ORACLE_HOME = c:\ ora \ 11gx64
和 TNS_ADMIN = c:\ ora \ 11gx64
还要在您的%PATH%中添加%ORACLE_HOME%
also add %ORACLE_HOME% in Your %PATH%
4)在创建的目录中,放入文件tnsnames.ora,并用连接字符串填充到db:
%ORACLE_HOME%** tnsnames.ora **
%ORACLE_HOME%**tnsnames.ora**
XE =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = XE)
)
)
->用您的主机名替换127.0.0.1
-> replace 127.0.0.1 with your hostname
->用您的SID替换XE
-> replace XE with your SID
5)我想您已经安装了Python.
->否则,请访问Python的下载页面
-> Otherwise visit Download page for Python
->安装python(撰写本文时为3.6.1)
-> Install python (3.6.1 in the time of writting)
-> If not installed install pip (https://pip.pypa.io/en/stable/installing/#do-i-need-to-install-pip)
->执行 python get-pip.py
6)下载并安装Visual C ++ 2015生成工具
->搜索Visual C ++ 2015生成工具 ->安装visualcppbuildtools_full.exe
-> Search for Visual C++ 2015 Build Tools -> Install visualcppbuildtools_full.exe
7)使用pip安装cx_oracle
pip install cx_oracle
(在撰写本文时,默认安装的版本5.3出现问题,因此必须安装版本6.0b2)
(in the time of writing there is trouble with default installed version 5.3 so the Version 6.0b2 has to be installed)
python -m pip install cx_Oracle --pre
在我看来,第一步对于conda和pip都是普遍的.
The first steps are universal in my honest opinion for both conda and pip.
这篇关于Anaconda 3.5(64位Windows)安装cx_Oracle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!