Deploying cx_Oracle in Windows

流过昼夜 提交于 2019-11-29 11:35:33

I tried a lot of ways to finally solve the problem. Since I think I should write a comprehensive answer, I will write the problems that I faced and their solutions respectively; hoping it can help others. I also changed the question's name to an appropriate one. Here's what I've been through during installation of cx_Oracle module in Windows 7 - 32 bit version(I think other versions of windows would have similar solutions, but I'm not sure):

  • I have tried to install cx_Oracle using easy_install and I got the error No oracle client installed. I have downloaded oracle basic instant client and oracle sdk instant client for windows from Oracle Official Website and installed it via following steps:

    Unzip oracle basic instant client into directory C:\oracle\instant_client_11_1\.

    Unzip oracle sdk instant client and copy folder sdk into the directory C:\oracle\instant_client_11_1\, consequently we have a directory as C:\oracle\instant_client_11_1\sdk\.

    Add C:\oracle\instant_client_11_1\ to the end of the PATH environment variable.

    Add a new variable named ORACLE_HOME and set C:\oracle\instant_client_11_1\ for the value.

    Restart computer.

  • I tried to install cx_Oracle using easy_install again and I got error command ‘gcc’ failed: no such file or directory and in some cases unable to find vcvarsall.bat; this was because I didn’t have a C++ compiler, so I followed these steps to solve it:

    Download Microsoft Visual C++ and install it.

    Download MinGW and install it; note that you must install GCC module.

    Add C:\MinGW\ and C:\MinGW\bin\(which contains gcc.exe) to the end of the PATH environment variable.

  • I tried to install cx_Oracle using easy_install again and I got error command ‘gcc’ failed with exit status 1; I tried this step to solve it:

    Open file C:\Python27\Lib\distutils\ cygwincompiler.py and remove all –mno-cygwin occurrences in this file; this is because recent versions of GCC has removed –mno-cygwin option and it shouldn’t be there.

  • I tried to install cx_Oracle using easy_install and it worked.

But during searching in the internet I found a couple of tricks that may be useful:

  • If you got error no module named win32api, it’s because you didn’t install win32 extensions of python on your computer you should download pywin32 module from Source Forge and install it.

  • If you didn’t succeed anyway, you can try an older version of cx_Oracle; but keep in mind all we talked about in the above lines. You can find all versions of cx_Oracle here.

  • If you want to use sqlplus you should do some other steps too. For this purpose search the internet.

You may want to try some pre-built binaries. Unfortunately, the installer is an MSI, so installation using them with virtualenv would not be possible.

I believe what you're referring to with the ora file is the TNS names file. If so, it's a plain text file with a particular format. This might help: http://www.orafaq.com/wiki/Tnsnames.ora. According to the FAQ, Oracle will look in the TNS_ADMIN directory for the file tnsnames.ora. Note that using a TNS names file may be optional. In many cases, you can drop what you would normally put in the TNS names file (so something like (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521))) (CONNECT_DATA=(SERVICE_NAME=ORA11)))) in the same place you would a TNS name.

Welcome to Oracle. Good luck. You'll need it. (Yes, everything is this complicated with Oracle.)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!