Do not install Oracle using cx_oracle

Source: Internet
Author: User

Using Python to connect to an Oracle database is a hassle, especially under Windows, where the Oracle database is installed by default, and the installation process can be problematic for users who do not want to install Oracle on their machines. The most common are as follows:

    1. Installation Error:distutils.errors.DistutilsSetupError:cannot Locate Oracle include files in ...

    2. Error running:cx_Oracle.InterfaceError:Unable to acquire Oracle environment handle ...

Find a lot of information from the network, the method is basically similar, but misleading, so deliberately experiment and record for future reference, and hope to help meet similar problems of friends. This installation environment is window 64bit+miniconda3-latest-windows-x86_64.exe+ Instantclient-basic-windows.x64-11.2.0.4.0.zip, other environments, such as python2.7, python3.5 and other versions of the Windows operating system and Instantclient-basic-windows.x64-12.1.0.2.0.zip can also be consulted.

Steps to resolve:

    • Download the. exe file for cx_oracle.

Using Easy_install or PIP under Windows will cause an error:distutils.errors.DistutilsSetupError:cannot Locate Oracle include files in ... , you need to install it using an. exe file. To open the URL https://pypi.python.org/pypi/cx_Oracle, select the link that is appropriate for your operating system, Python version, and Oracle version of the page to download.

    • Download Oracle Instant Client

? Download Oracle Instant Client for Microsoft Windows (x64) from Oracle's official website, which must be downloaded from the English website, the Chinese site is slow to update, the latest version is 11.2.0.3.0, and the download speed is very slow. Download here is the 11.2.0.4.0 version, the other version did not try. Download unzip to the target folder, this time decompression into D:\software\Oracle\instantclient_11_2 , and add the path to the system environment variable, named Oracle_home, add Oracle_home to path, otherwise will error Cx_oracle.interfaceerror: Unable to acquire Oracle environment handle , in this case:oracle_home=d:\software\oracle\instantclient_11_ 2 Once the above steps are complete, re-enter the python interactive environment and test with the following code:

>>> Import cx_oracle>>> db=cx_oracle.connect (' Rhin/[email protected]/imis ') >>> print ( Db.version) 11.2.0.1.0>>>

At this point, the entire process is complete. Note that you do not need to install Oracle on this machine, and you do not need to add tnsnames.ora files to the new Network/admin directory, not to move Oci.dll to Site-packages. the whole process refers to the fresh water of the sky | Python cx_oracle Installation Notes, thanks here. This article should also solve the problem that Linux does not install Oracle using SQLAlchemy, but does not validate it accordingly.

This article is from the "Apprentice's Garden" blog, please be sure to keep this source http://592tch.blog.51cto.com/2861477/1857724

Do not install Oracle using cx_oracle

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.