In this article, we will learn how to install cx_Oracle in Python on MacOS. The cx_Oracle is a Python extension module that enables access to Oracle Database. It conforms to the Python database API 2.0 specification with a considerable number of additions and a couple of exclusions. See the homepage for a feature list.
Installation:
Method 1: Using pip to install cx_Oracle Package
Follow the below steps to install the cx_Oracle package on macOS using pip:
Step 1: Install the latest Python3 in MacOS
Step 2: Check if pip3 and python3 are correctly installed.
python3 --version
pip3 --version

Step 3: Upgrade your pip to avoid errors during installation.
pip3 install --upgrade pip

Step 4: Enter the following command to install cx_Oracle using pip3.
pip3 install cx_Oracle

Method 2: Using setup.py to install cx_Oracle
Follow the below steps to install the cx_Oracle package on macOS using the setup.py file:
Step 1: Download the latest source package of cx_Oracle for python3 from here.
curl https://files.pythonhosted.org/packages/be/bf/1dc153a103680b0831299e119c2281ecdec93fcfd27dd0a774a79a4f7267/cx_Oracle-8.2.1.tar.gz > cx_Oracle.tar.gz

Step 2: Extract the downloaded package using the following command.
tar -xzvf cx_Oracle.tar.gz

Step 3: Go inside the folder and Enter the following command to install the package.
Note: You must have developer tools for XCode MacOS installed in your system
cd cx_Oracle-8.2.1
python3 setup.py install

Verifying cx_Oracle installation on macOS:
Make the cx_Oracle import in your python terminal to verify if the installation has been done properly:
import cx_Oracle

If there is any error while importing the module then is not installed properly.