This article mainly introduced the Python installs the Cx_oracle module frequently asked questions and the solution, has analyzed the python in the Windows platform and the Linux platform installs the Cx_oracle module frequently asked questions, the solution and the related attention matter, needs the friend to refer to the next
The examples in this article describe common problems and workarounds for Python installation cx_oracle modules. Share to everyone for your reference, as follows:
When installing or using cx_oracle, you need to use Oracel's link library, such as libclntsh.so.10.1, or there will be a variety of error messages.
Install the Oracle Instant client to get this link library and avoid installing the hundreds of Mega Oracle client.
Software Download Address:
Cx_oracle's homepage: cx-oracle.sourceforge.net/
Required download address for the Oracle link library: www.oracle.com/technology/software/tech/oci/instantclient/index.html
Common Errors and workarounds:
I. Win32 BINARY Installation
After installing Cx_oracle-5.0-10g.win32-py2.6.msi under Windows, the DLL fails to load when it is imported, as follows:
IDLE 2.6.1
>>> Import Cx_oracletraceback (most recent): File ' <pyshell#0> ', line 1, in <module> im Port Cx_oracleimporterror:dll Load failed: The specified program could not be found.
Workaround:
Download Instantclient-basic-win32-10.2.0.4.zip from the Oracle site, and after extracting it, copy the Oci.dll file into the Python installation directory lib/site-packages, such as c:/ Python26/lib/site-packages
Two. Linux under binary installation
Under linux_x86_64, install cx_oracle-5.0.1-10g-py24-1.x86_64.rpm times wrong.
[root@bj-update-01 ~]# rpm-ivh cx_oracle-5.0.1-10g-py24-1.x86_64.rpmerror:failed dependencies: libclntsh.so.10.1 () (64bit) is needed by cx_oracle-5.0.1-1.x86_64
Workaround:
Reference Cx-oracle.sourceforge.net/build.txt
Download the Basic-10.2.0.4.0-linux-x86_64.zip to/opt directory from the Oracle site and unzip it to see libclntsh.so.10.1 in the/opt/instantclient_10_2 directory
Setting environment variables
Vi/root/.bash_profile
Add the following two lines:
Export Oracle_home=/opt/instantclient_10_2export ld_library_path= $LD _library_path: $ORACLE _home
Run Source/root/.bash_profile make changes take effect
Create a symbolic link to this link library
CD $ORACLE _homeln-s libclntsh.so.x.x libclntsh.so
Reinstall Cx_oracle
Note that the--nodeps parameter is added, otherwise the error will be reported
[root@bj-update-01 ~]# RPM-IVH--nodeps cx_oracle-5.0.1-10g-py24-1.x86_64.rpm#5.0.3 version does not add--nodeps parameter
Three. Linux under source code installation
Set environment variables and symbolic links as above, under Linux_x86_64 Source code installation, run Python setup.py build, compile-time error message as follows:
CONNECTION.C:1169: Warning: statement does not work
connection.c:1171: Error: ' Udt_connection ' does not have a member named ' Environment '
connection.c:1172: Warning: Conversion between incompatible pointer types when passing parameter 1 (belonging to ' Environment_checkforerror ')
connection.c:1172: Warning: Conversion between incompatible pointer types when passing parameter 2 (belonging to ' Environment_checkforerror ')
connection.c:1172: Error: Too many arguments supplied to function ' Environment_checkforerror '
connection.c:1176: Error: ' Udt_connection ' does not have a member named ' SessionHandle '
Workaround:
5.0.3 version of this error does not appear, note that there is an include directory under Oracle_home, this directory to compile the required source files, the source file is not included in the Oracle Instant client. I copied it from the D:/oracle/product/10.2.0/client_1/oci/include directory of the Windows client.
Four. Import Error
>>> Import Cx_oracletraceback (most recent): File ' <stdin> ', line 1, in? Importerror:/usr/lib/oracle/10.2.0.4/client64//lib/libnnz10.so:cannot Restore segment prot after reloc:permission Denied>>> Import Cx_oracletraceback (most recent): File ' <stdin> ', line 1, in? Importerror:/usr/lib/oracle/10.2.0.4/client64//lib/libclntsh.so.10.1:cannot Restore segment prot after Reloc: Permission denied>>> Import cx_oracle>>>
This is because of the selinux limit, run the following command to cancel the restriction:
Chcon-t texrel_shlib_t CD $ORACLE _home/libnnz10.sochcon-t texrel_shlib_t CD $ORACLE _home/libclntsh.so.10.1
Five, run-time error
Traceback (most recent): File "oracle_conn.py", line 9, in? Connection = cx_oracle.connection (u "ORACLE/ORACLE123@CCIP") cx_Oracle.InterfaceError:Unable to acquire Oracle Environment handle
Or SELinux limit, set SELinux to Disabled
Turn off SELinux:
Run command: Vim/etc/selinux/config
Change selinux=enforcing or permissive to Disabled
Run command: Setenforce 0
Six. There is a problem with the Unicode installation package
Traceback (most recent): File "./oracle_conn.py", line A, in? Folderids=cursor.fetchmany (cx_oracle.databaseerror:oci-22061:message) 22061 not found; No message file for Product=rdbms, Facility=oci; Arguments: [T
"Recommended"
1. Python Free video tutorial
2. Python's application in Data science
3. Python Basics Getting Started tutorial