Errors and solutions encountered when installing cx_Oracle
This article mainly introduces the common problems and solutions for installing the cx_Oracle module in Python. It gives examples and analyzes the common problems, solutions and related precautions for installing the cx_Oracle module in Python on the Windows platform and Linux platform. Friends in need can refer to the following
The examples in this article describe common problems and solutions for installing the cx_Oracle module in Python. Share it with everyone for your reference, the details are as follows:
When installing or using cx_Oracle, you need to use the Oracle link library, such as libclntsh.so.10.1, otherwise there will be various error messages.
You can get this link library by installing Oracle Instant Client, avoiding the installation of hundreds of megabytes of Oracle Client.
Software download address:
cx_Oracle’s homepage: cx-oracle.sourceforge.net/
Download of necessary Oracle link libraries Address: www.oracle.com/technology/software/tech/oci/instantclient/index.html
Common errors and solutions:
一.win32 binary installation
After installing cx_Oracle-5.0-10g.win32-py2.6.msi under windows, when importing, it reports that DLL is loading The failed error is as follows:
IDLE 2.6.1
>>> import cx_Oracle Traceback (most recent call last): File "<pyshell#0>", line 1, in <module> import cx_Oracle ImportError: DLL load failed: 找不到指定的程序。
Solution:
Download instantclient-basic-win32-10.2 from the Oracle site. 0.4.zip, after decompression, copy the oci.dll file to Lib/site-packages in the Python installation directory, such as C:/Python26/Lib/site-packages
2. Binary installation under linux
Under linux_x86_64, an error occurs when installing cx_Oracle-5.0.1-10g-py24-1.x86_64.rpm.
[root@BJ-UPDATE-01 ~]# rpm -ivh cx_Oracle-5.0.1-10g-py24-1.x86_64.rpm error: Failed dependencies: libclntsh.so.10.1()(64bit) is needed by cx_Oracle-5.0.1-1.x86_64
Solution:
Refer to cx-oracle.sourceforge.net/BUILD.txt
Download basic-10.2.0.4 from the Oracle site. 0-linux-x86_64.zip to the /opt directory and unzip it, you will see libclntsh.so.10.1 in the /opt/instantclient_10_2 directory
Set environment variables
vi /root/.bash_profile
Add the following two lines:
export ORACLE_HOME=/opt/instantclient_10_2 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ORACLE_HOME
Run source /root/.bash_profile to make the changes take effect
Establish a symbolic link to this link library
cd $ORACLE_HOME ln -s libclntsh.so.x.x libclntsh.so
Reinstall cx_Oracle
Be careful to add the --nodeps parameter, otherwise the above 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版本不用加--nodeps参数
3. Source code installation under Linux
Set the environment variables and symbolic links as above, install the source code under linux_x86_64, run python setup.py build, the error message during compilation is as follows:
Connection.c:1169: warning: statement does not work
Connection.c:1171: error: 'udt_Connection' has no member named 'environment'
Connection.c:1172: warning: passing parameter 1 (of Converting between incompatible pointer types when passing argument 2 (of 'Environment_CheckForError')
Connection.c:1172: warning: Converting between incompatible pointer types when passing argument 2 (of 'Environment_CheckForError')
Connection.c:1172 : Error: Too many arguments supplied to function 'Environment_CheckForError'
Connection.c:1176: Error: 'udt_Connection' has no member named 'sessionHandle'
Solution:
This error does not occur in version 5.0.3. Please note that there must be a include directory under ORACLE_HOME. There must be The source files required for compilation are not included in the Oracle Instant Client. I copied it from the directory D:/oracle/product/10.2.0/client_1/oci/include on the Windows client.
4.Import error
>>> import cx_Oracle Traceback (most recent call last): 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_Oracle Traceback (most recent call last): 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 restrictions of SELinux. Run the following command to cancel the restrictions:
chcon -t texrel_shlib_t cd $ORACLE_HOME/libnnz10.so chcon -t texrel_shlib_t cd $ORACLE_HOME/libclntsh.so.10.1
5. Runtime error
Traceback (most recent call last): File "oracle_conn.py", line 9, in ? connection = cx_Oracle.Connection(u"oracle/oracle123@CCIP") cx_Oracle.InterfaceError: Unable to acquire Oracle environment handle
It is still a limitation of SELinux, set SELinux to disabled
Turn off selinux:
Run the command: vim /etc/selinux/config
Change selinux=enforcing or permissive to disabled
Run the command: setenforce 0
6. UNICODE There is a problem with the installation package
Traceback (most recent call last): File "./oracle_conn.py", line 22, in ? folderIds=cursor.fetchmany(10) cx_Oracle.DatabaseError: OCI-22061: Message 22061 not found; No message file for product=RDBMS, facility=OCI; arguments: [T
[Related recommendations]
2. Application of Python in Data Science
3. Basic Introduction to Python Tutorial
The above is the detailed content of Errors and solutions encountered when installing cx_Oracle. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

To run Python code in Sublime Text, you need to install the Python plug-in first, then create a .py file and write the code, and finally press Ctrl B to run the code, and the output will be displayed in the console.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

Python is more suitable for beginners, with a smooth learning curve and concise syntax; JavaScript is suitable for front-end development, with a steep learning curve and flexible syntax. 1. Python syntax is intuitive and suitable for data science and back-end development. 2. JavaScript is flexible and widely used in front-end and server-side programming.

Golang is better than Python in terms of performance and scalability. 1) Golang's compilation-type characteristics and efficient concurrency model make it perform well in high concurrency scenarios. 2) Python, as an interpreted language, executes slowly, but can optimize performance through tools such as Cython.

Writing code in Visual Studio Code (VSCode) is simple and easy to use. Just install VSCode, create a project, select a language, create a file, write code, save and run it. The advantages of VSCode include cross-platform, free and open source, powerful features, rich extensions, and lightweight and fast.

Running Python code in Notepad requires the Python executable and NppExec plug-in to be installed. After installing Python and adding PATH to it, configure the command "python" and the parameter "{CURRENT_DIRECTORY}{FILE_NAME}" in the NppExec plug-in to run Python code in Notepad through the shortcut key "F6".
